/* ===== Base / tipografía segura en móviles iOS ===== */
html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  font-size:100%;
}

/* ===== Layout principal ===== */
.producto-detalle-container{
  max-width:1200px;
  margin:40px auto;
  padding:0 20px;
  display:grid;
  grid-template-columns:1fr;
  grid-template-areas:"gallery" "info";
  gap:28px;
}
.producto-imagenes{ grid-area:gallery; min-width:0; min-height:0; }
.producto-info{ grid-area:info; min-width:0; min-height:0; }

@media (min-width:901px){
  .producto-detalle-container{
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    grid-template-areas:"gallery info";
    gap:40px; align-items:start;
  }
}

/* =====================================================
   GALERÍA — Marco blanco (letterbox) SIN recortar
   ===================================================== */

/* Altura uniforme y responsiva para TODAS las slides */
:root{
  /* antes: clamp(360px, 62vh, 680px) */
  --gallery-h: clamp(600px, 78vh, 800px);
  --card-media-h: clamp(180px, 24vw, 240px);
  --card-radius: 10px;
  --title-lh: 1.3;
  --title-lines: 3;
  --card-gap: 12px;            /* ← pequeño espacio entre imagen y nombre */
}

/* Contenedor del marco (usa también zoom-container en tu HTML) */
.gallery-frame,
.zoom-container{
  height: 100%;
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#fff;          /* marco blanco */
  border:1px solid #eee;
  border-radius:10px;
  overflow:hidden;          /* mantiene el zoom dentro del marco */
  box-sizing:border-box;
  padding:0;                /* sin padding extra */
}

/* Imagen dentro del marco: jamás se recorta */
.gallery-frame > img,
.zoom-image{
  width:100%;
  height:100%;
  max-width:100%;
  max-height:100%;
  object-fit: contain;      /* reduce grandes, muestra bordes si falta */
  object-position: center;  /* centrado vertical/horizontal */
  display:block;
  transition: transform .12s ease;
  transform-origin: center center;
}

/* Contenedor Swiper principal */
.mySwiperMain{
  width:100%;
  margin-bottom:10px;
  border-radius:10px;
}

/* Cada slide contiene el marco blanco */
.mySwiperMain .swiper-slide{
  height: var(--gallery-h) !important;
  display:block;
}

/* Compat: si sigues usando .zoom-container/.zoom-image en el HTML */
.zoom-container{ padding:0; }
.zoom-container .zoom-image{ object-fit:contain; }

/* ===== Miniaturas (también sin recortar) ===== */
.mySwiperThumbs{
  height:auto;
  box-sizing:border-box;
  padding:40px 34px;   /* espacio para flechas */
  position:relative;
}
.mySwiperThumbs .swiper-wrapper{ align-items:center; }
.mySwiperThumbs .swiper-slide{
  width:84px; height:84px; cursor:pointer;
  border:1px solid #ddd; border-radius:6px;
  background:#fff; opacity:.6;
  display:grid; place-items:center;
  overflow:hidden; padding:6px;              /* bordes blancos uniformes */
  transition:opacity .2s, border-color .2s, box-shadow .2s, transform .2s;
}
.mySwiperThumbs .swiper-slide-thumb-active{
  opacity:1; border:2px solid #333; box-shadow:0 2px 6px rgba(0,0,0,.08);
}
.mySwiperThumbs img{
  max-width:100%;
  max-height:100%;
  width:auto; height:auto;
  object-fit:contain;            /* no recortar miniaturas */
  display:block;
  border-radius:4px;
}

/* Flechas de miniaturas */
.thumbs-prev, .thumbs-next{
  --swiper-navigation-size:18px;
  position:absolute; top:50%; transform:translateY(-50%);
  width:28px; height:28px; border-radius:50%;
  background:rgba(255,255,255,.95);
  border:1px solid #ddd; box-shadow:0 2px 6px rgba(0,0,0,.1);
  color:#333; z-index:2; transition:background .2s, color .2s;
}
.thumbs-prev:hover, .thumbs-next:hover{ background:#333; color:#fff; }
.thumbs-prev{ left:6px; }
.thumbs-next{ right:6px; }

/* ===== Info del producto ===== */
.producto-info h1{ font-size:2rem; color:#444; margin:.5rem 0; }
.producto-info .precio{ font-size:1.5rem; font-weight:700; color:#444; margin:.5rem 0 1rem; }

/* ===== Formulario de configuración (opciones) ===== */
.form-config{ display:flex; flex-direction:column; gap:15px; margin-bottom:20px; }
.product-options-box {
  background: #fff;
  border: 1px solid #ddd;
  padding-right: 1.5rem; 
  padding-left: 1.5rem; 
  padding-bottom: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  box-sizing: border-box;          /* ← asegura que el alto incluye padding/borde */
}
.product-option-group{ margin-bottom:0; }
.product-option-label{
  display:block; font-weight:600; font-size:.95rem; margin:.75rem 0 .25rem; color:#555;
}
.required{ color:#aaa; font-size:.65rem; text-transform:uppercase; margin-left:.3rem; }

.product-option-input,
.product-option-select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background-color: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.product-option-input:focus, .product-option-select:focus{
  outline:none; border-color:#5e2ca5; box-shadow:0 0 0 2px rgba(94,44,165,.15);
}
.product-option-select{
  background-image:url("data:image/svg+xml;utf8,<svg fill='gray' height='16' viewBox='0 0 24 24' width='16' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat:no-repeat; background-position:right .8rem center; background-size:16px; padding-right:2rem; cursor:pointer;
}

/* Opciones por imágenes */
.image-select-group{
  display:flex; flex-wrap:wrap; gap:10px;
}

.image-option{ position:relative; }
.image-option::after{
  content: attr(data-label) attr(data-extraformatted);
  position:absolute;
  left:50%;
  transform: translateX(-50%);
  white-space:nowrap;
  font-size:.8rem; font-weight:600;
  color:#333; background:#fff;
  border:1px solid #ccc; border-radius:6px;
  padding:6px 10px; box-shadow:0 4px 12px rgba(0,0,0,.12);
  opacity:0; pointer-events:none; transition:opacity .12s ease;
  z-index:5000;
}
.image-option:hover::after,
.image-option:focus-within::after{ opacity:1; }
/* Colocación dinámica (opuesto al preview) */
.image-option.tip-above::after{        /* tooltip ARRIBA de la miniatura */
  bottom: calc(100% + 8px);
  top: auto;
}
.image-option.tip-below::after{        /* tooltip ABAJO de la miniatura */
  top: calc(100% + 8px);
  bottom: auto;
}
.image-option input{ display:none; }
.image-wrapper{
  position:relative; width:70px; height:70px; border-radius:6px; overflow:hidden;
  border:2px solid transparent; transition:all .25s ease; z-index:1; background:#fff;
  display:grid; place-items:center; 
}
.image-wrapper img{ max-width:100%; max-height:100%; width:auto; height:auto; object-fit:contain; cursor:pointer; }
.image-option input:checked + .image-wrapper{ border-color:#5e2ca5; }
.caption{
  position:absolute; left:0; right:0; bottom:0; background:rgba(0,0,0,.7); color:#fff;
  font-size:.75rem; padding:4px 6px; text-align:center; opacity:0; transform:translateY(100%); transition:all .25s ease;
}
.image-wrapper:hover .caption{ opacity:1; transform:translateY(0); }

/* --- Overlay flotante para la previsualización (no afecta layout) --- */
#image-hover-preview{
  position:fixed;
  left:0; top:0;
  max-width:92vw;         /* tope por seguridad */
  max-height:70vh;
  background:#fff; border:1px solid #ddd; border-radius:12px;
  box-shadow:0 12px 30px rgba(0,0,0,.18);
  padding:10px;           /* borde apenas mayor que la imagen */
  display:inline-block;   /* que tome el tamaño del contenido */
  opacity:0; transform: translateY(6px);
  pointer-events:none;
  transition:opacity .15s ease, transform .15s ease;
  z-index:6000;
}

#image-hover-preview.visible{ opacity:1; transform: translateY(0); }

/* La imagen manda el tamaño; con topes de pantalla */
#image-hover-preview img{
  display:block;
  max-width: min(520px, 92vw);
  max-height: 35vh;
  width:auto;
  height:auto;
  object-fit:contain;
  border-radius:10px;
}

/* Radios / botones */
.radio-group{ display:flex; flex-direction:column; gap:6px; margin-top:.1rem; }
.radio-option{ display:flex; align-items:center; gap:6px; font-size:.9rem; color:#444; cursor:pointer; }
.radio-option input{ accent-color:#333; transform:scale(1.1); }
.button-group{ display:flex; flex-wrap:wrap; gap:8px; }
.button-option input{ display:none; }
.button-option span{
  display:inline-block; padding:6px 12px; border:2px solid #aaa; border-radius:4px; font-size:.9rem; color:#333; background:#fff; transition:.2s;
}
.button-option:hover span{ border-color:#333; }
.button-option input:checked + span{ border-color:#333; background:#f9f9f9; font-weight:600; }

/* Cantidad */
.product-quantity-group{ margin:.25rem 0 .25rem; }
.quantity-controls{ display:flex; align-items:center; gap:2px; }
.qty-btn{
  padding:4px 8px; font-size:.9rem; border:1px solid #ccc; background:#f5f5f5; cursor:pointer; border-radius:4px;
}
.qty-btn:hover{ background:#e3e3e3; }
.quantity-input{ width:30px; text-align:center; padding:5px; border-radius:4px; border:1px solid #ccc; }

/* Botones CTA */
.botones{ display:flex; gap:20px; margin-top:15px; flex-wrap:wrap; }
.add-cart,.add-wishlist{
  padding:12px 24px; border-radius:5px; cursor:pointer; font-weight:600; font-size:.95rem; border:none; transition:background-color .3s;
}
.add-cart{ background:#333; color:#fff; }
.add-cart:hover{ background:#555; }
.add-wishlist{ background:#f2f2f2; color:#333; border:1px solid #ccc; }
.add-wishlist:hover{ background:#e0e0e0; }

/* ===== Tabs ===== */
.producto-tabs-container{ max-width:1200px; margin:20px auto 0; padding:0 20px; }
.producto-tabs-container .tab-buttons{ display:flex; flex-wrap:wrap; gap:10px; }
.producto-tabs-container .tab-btn{
  padding:10px 20px; background:#f2f2f2; border-radius:5px; border:none; cursor:pointer; font-weight:600; transition:.3s;
}
.producto-tabs-container .tab-btn:hover{ background:#ddd; }
.producto-tabs-container .tab-btn.active{ background:#333; color:#fff; }
.producto-tabs-container .tab{
  display:none; margin-top:1rem; font-size:.95rem; line-height:1.6; color:#444;
  overflow-x:hidden; overflow-wrap:anywhere; word-break:break-word; box-sizing:border-box; 
}
.producto-tabs-container .tab.active{ display:block; }
.producto-tabs-container .tab figure{ max-width:100%; margin:1rem auto; }
.producto-tabs-container .tab img{ display:block; max-width:100% !important; height:auto !important; }
.producto-tabs-container .tab iframe,
.producto-tabs-container .tab embed,
.producto-tabs-container .tab object,
.producto-tabs-container .tab video{ max-width:100%; width:100%; border:0; }
.producto-tabs-container .tab table{ width:100% !important; max-width:100%; border-collapse:collapse; table-layout:auto; }
.producto-tabs-container .tab pre, .producto-tabs-container .tab code{ white-space:pre-wrap; word-break:break-word; }

/* Videos responsivos */
.video-wrapper{ position:relative; width:100%; padding-top:56.25%; background:#000; }
.video-wrapper iframe{ position:absolute; inset:0; width:100%; height:100%; border:0; }

/* ===== Productos relacionados (card reusada) ===== */
.prin_word{
  color:#aaa; text-align:center; border-bottom:2px solid #ddd; padding-bottom:8px; margin:0 0 20px;
}
.productos-grid{ display:grid; grid-template-columns:repeat(5,1fr); gap:10px; padding:0 20px; }
.producto-card{
  background: #fff;
  border-radius: var(--card-radius);
  border: 1px solid #e7e7e7;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  padding: 10px 12px 12px;
  text-decoration: none; color: inherit;
  display: grid;
  grid-template-rows: var(--card-media-h) 2.6em 1.6em; /* imagen | título | precio */
  row-gap: 8px;
  height: calc(var(--card-media-h) + 2.6em + 1.6em + 30px); /* alto EXACTO e igual */
  transition: transform .2s, box-shadow .2s, border-color .2s;
  display: grid;
  grid-template-rows:
    var(--card-media-h)                               /* área de imagen fija  */
    calc(var(--title-lines) * var(--title-lh) * 1em)  /* título (hasta 3 líneas) */
    1.6em;                                            /* precio */
  row-gap: var(--card-gap);
  height: calc(
    var(--card-media-h)
    + calc(var(--title-lines) * var(--title-lh) * 1em)
    + 1.6em + 30px
  );
}
.producto-card:hover{ transform:translateY(-4px); box-shadow:0 4px 10px rgba(0,0,0,.12); border-color:#bbb; }
.producto-card img{
  max-width: 100%;
  max-height: 100%;
  width: auto;            /* no estires: mantiene proporción */
  height: auto;
  margin: auto;           /* centra H/V dentro de la celda de grid */
  display: block;
  object-fit: contain;    /* completa dentro del marco sin recortar */
  object-position: center;
  background: #f7f7f8;
  border-radius: 8px;
}
.producto-card h2{
  font-size: 0.95rem !important;
  line-height: var(--title-lh);
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  text-align: center;
  overflow-wrap: anywhere;
}
.producto-card p.precio{
  font-size: 0.95rem !important;
  font-weight: 600;
  color: #666;
  margin: 0;
  text-align: center;
  line-height: 1.6;
}

/* Desactiva el tooltip ::after cuando usemos overlay JS */
body.floating-tooltips .image-option::after { display: none !important; }

/* Tooltip flotante que no se recorta por overflow */
#option-tooltip{
  position: fixed;
  left: 0; top: 0;
  padding: 6px 10px;
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 7000;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
#option-tooltip.visible{ opacity:1; transform: translateY(0); }

/* Forzar texto normal dentro de los tabs de producto */
.producto-tabs-container .tab {
  font-weight: 400;
}

.producto-tabs-container .tab p,
.producto-tabs-container .tab li {
  font-weight: 400;
}

/* ===== Opciones del producto: altura = altura de la galería ===== */
@media (min-width: 901px){
  /* Alto del cuadro = --opts-h (si no existe, usa --gallery-h) */
  .product-options-box{
    height: var(--opts-h, var(--gallery-h));
    max-height: none;                 /* ya no limitamos por viewport */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 1.2rem;
  }

  /* Scrollbar limpio */
  .product-options-box::-webkit-scrollbar{ width:10px; }
  .product-options-box::-webkit-scrollbar-track{ background:#f2f2f2; border-radius:8px; }
  .product-options-box::-webkit-scrollbar-thumb{
    background:#c9c9c9; border-radius:8px; border:2px solid #f2f2f2;
  }
  .product-options-box::-webkit-scrollbar-thumb:hover{ background:#b5b5b5; }
}

/* En móviles, que fluya normal */
@media (max-width: 900px){
  .product-options-box{ height:auto; max-height:none; overflow:visible; }
}

/* ===== Responsive grid relacionados ===== */
@media (max-width:1200px){ .productos-grid{ grid-template-columns:repeat(3,1fr); } }
@media (max-width: 1024px){
  :root{ --card-media-h: clamp(170px, 30vw, 220px); }
}
@media (max-width:768px){ .productos-grid{ grid-template-columns:repeat(2,1fr); } }
@media (max-width: 640px){
  :root{ --card-media-h: clamp(150px, 42vw, 200px); }
}

/* ===== Utilidad: asegura que los iframes/imágenes inline no fuercen scroll ===== */
@media (max-width:600px){
  .producto-tabs-container .tab .align-left,
  .producto-tabs-container .tab .align-right{
    float:none !important; margin:.5rem auto !important; display:block !important;
  }
}

/* En móviles muy pequeños, aprovéchate un poco más de la altura disponible */
@media (max-width: 480px){
  :root{
    --gallery-h: clamp(360px, 72vh, 720px);
  }
}
