/* ----------------- WRAPPER ----------------- */
.size-selector {
  margin: 8px 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* ----------------- EACH BUTTON ----------------- */
.size-selector button {
  border: 2px solid #48aa9d;
  background: #ffffff;
  color: #48aa9d;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 5px;
  min-width: 50px;
  text-align: center;
  transition: all 0.3s ease;
  margin: 0 5px 5px 0;
  position: relative;
  box-sizing: border-box;
}

.size-selector button:hover:not(.out-of-stock) {
  background: #48aa9d;
  color: #fff;
}

/* Selected button with shine */
.size-selector button.selected {
  background: #48aa9d !important;
  color: #ffffff !important;
  border-color: #48aa9d !important;
  box-shadow: 0 0 8px rgba(72, 170, 157, 0.7);
  animation: shineBtn 1.5s ease-in-out forwards;
}

/* Shining animation */
@keyframes shineBtn {
  0% {
    box-shadow: 0 0 0 rgba(72, 170, 157, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(72, 170, 157, 0.8);
  }
  100% {
    box-shadow: 0 0 0 rgba(72, 170, 157, 0.5);
  }
}

/* Out of stock */
.size-selector button.out-of-stock {
  position: relative;
  background: #f8f8f8;
  color: #d9534f;
  border: 2px solid #d9534f;
  cursor: not-allowed;
  pointer-events: none;
}

.size-selector button.out-of-stock::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom right,
    transparent calc(50% - 1px),
    #d9534f calc(50% - 1px),
    #d9534f calc(50% + 1px),
    transparent calc(50% + 1px)
  );
}

/* ----------------- FORCE NEW LINE FOR SIZE GUIDE ----------------- */
.size-selector-wrapper {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

.single-product table.variations th.label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.single-product table.variations th.label label {
  display: block;
  margin-bottom: 0;
}

.size-guide-text-container {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  margin-bottom: 6px;
  order: 2;
  box-sizing: border-box;
  overflow: hidden;
}

/* Guide des tailles — couleurs dans single-product.css */

/* ----------------- #4 BOUTON GUIDE DE TAILLE (sous le sélecteur) ----------------- */
.size-guide-below-wrapper {
  display: block;
  width: 100%;
}

.size-guide-below {
  cursor: pointer;
  width: 100%;
  display: block;
  box-sizing: border-box;
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  background: #111111;
  border: 2px solid #111111;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.size-guide-below:hover {
  background: #2d2d2d;
  color: #fff;
  border-color: #2d2d2d;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* ----------------- POPUP STYLES ----------------- */
.size-guide-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  overflow: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.size-guide-popup-overlay.show {
  display: flex;
  opacity: 1;
}

.size-guide-popup {
  background: #fff;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 25px;
  border-radius: 12px;
  position: relative;
  margin: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transform: scale(0.95);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.size-guide-popup-overlay.show .size-guide-popup {
  transform: scale(1);
  opacity: 1;
}

.size-guide-popup-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  cursor: pointer;
  font-weight: bold;
  z-index: 10000;
  background: #fff;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 1px solid #ddd;
}

/* ----------------- ZOOMABLE IMAGE ----------------- */
.zoom-wrapper {
  width: 100%;
  overflow: hidden;
  touch-action: none; /* For pinch zoom */
  border-radius: 8px;
}

.zoom-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  transform-origin: center center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: grab;
  border-radius: 8px;
}

.zoom-wrapper img:hover {
  transform: scale(1.15);
  box-shadow: 0 15px 40px rgba(72, 170, 157, 0.3);
}

.zoom-wrapper img:active {
  cursor: grabbing;
}

/* ----------------- RESPONSIVE ----------------- */
@media (max-width: 991px) {
  .single-product .size-selector {
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 3px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .single-product .size-selector button {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: auto !important;
    margin: 0 !important;
    padding: 7px 2px !important;
    font-size: 12px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .single-product .size-guide-link,
  .single-product #open-size-guide {
    padding: 12px 10px !important;
    font-size: 0.85rem !important;
    letter-spacing: 0.02em !important;
  }
}

@media (max-width: 768px) {
  .size-guide-popup-overlay {
    padding: 10px;
    display: none !important;
    align-items: center;
    justify-content: center;
  }

  .size-guide-popup-overlay.show {
    display: flex !important;
  }

  .size-guide-popup {
    width: 95%;
    padding: 20px;
    max-height: 85vh;
    transform: none;
  }

  .size-guide-popup-close {
    width: 40px;
    height: 40px;
    font-size: 30px;
    top: 5px;
    right: 10px;
    z-index: 10001;
  }
}

@media (max-width: 480px) {
  .size-guide-popup {
    width: 98%;
    padding: 15px;
    max-height: 80vh;
  }

  .size-guide-popup-close {
    width: 35px;
    height: 35px;
    font-size: 25px;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  .size-guide-popup-close {
    min-width: 44px;
    min-height: 44px;
  }

}
