/* ═══════════════════════════════════════════
   Tema v2 — Producto
   Prefijo: v2p-  · Conserva las clases que usa js/Product.js
   Acento (color de la tienda): precio en oferta, descuento, favorito.
   Tinta: botón de compra y selección de variante/presentación.
═══════════════════════════════════════════ */

.v2p-sticky,
.v2p-sticky * {
  box-sizing: border-box;
}

/* ── Ruta ─────────────────────────────────── */

.v2p-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 14px;
  overflow: hidden;
  color: var(--v2-muted);
  font-size: 12px;
  white-space: nowrap;
}

.v2p-crumbs a {
  flex-shrink: 0;
  color: var(--v2-muted);
  text-decoration: none;
}

.v2p-crumbs a:hover {
  color: var(--v2-ink);
}

.v2p-crumbs-current {
  overflow: hidden;
  color: var(--v2-ink);
  text-overflow: ellipsis;
}

/* ── Layout ───────────────────────────────── */

.v2p-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

/* ── Galería (clases de Product.js) ───────── */

.v2p-gallery {
  min-width: 0;
}

.v2p-stage {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--v2-line);
  border-radius: 22px;
  background: #fff;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
}

.v2p-stage .carousel-slides {
  display: flex;
  height: 100%;
  transition: transform 0.35s ease;
}

.v2p-stage .carousel-slide {
  flex: 0 0 100%;
  height: 100%;
}

.v2p-stage .detalle-img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 8%;
  object-fit: contain;
  pointer-events: none;
}

.v2p-stage .carousel-control {
  position: absolute;
  top: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--v2-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--v2-ink);
  cursor: pointer;
  transform: translateY(-50%);
}

.v2p-stage .carousel-control.prev {
  left: 12px;
}

.v2p-stage .carousel-control.next {
  right: 12px;
}

.v2p-stage .carousel-control.is-hidden {
  display: none !important;
}

.v2p-stage .carousel-indicators {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.v2p-stage .indicator {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d4d4d9;
  cursor: pointer;
  transition:
    width 0.2s ease,
    background-color 0.2s ease;
}

.v2p-stage .indicator.active {
  width: 18px;
  background: var(--v2-ink);
}

.v2p-stage .indicator.is-hidden {
  display: none;
}

.carousel-thumbs {
  display: none;
}

/* ── Información ──────────────────────────── */

.v2p-info {
  min-width: 0;
}

.v2p-cat {
  margin: 0;
  color: var(--v2-muted);
  font-size: 12px;
  font-weight: 500;
}

.v2p-name {
  margin: 4px 0 0;
  color: var(--v2-ink);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* Precio (Product.js reescribe este bloque con las mismas clases) */
.v2p-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 12px;
}

.v2p-price .precio,
.v2p-price .precio-oferta {
  color: var(--v2-ink);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.v2p-price .precio-original {
  color: var(--v2-muted);
  font-size: 15px;
  text-decoration: line-through;
}

.v2p-price .descuento-badge {
  align-self: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--v2-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.v2p-block {
  margin-top: 20px;
}

.v2p-block[hidden] {
  display: none;
}

.v2p-label {
  margin: 0 0 10px;
  color: var(--v2-muted);
  font-size: 13px;
}

.v2p-label strong {
  color: var(--v2-ink);
  font-weight: 600;
}

/* Variantes */
.v2p-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.v2p-variants .variant-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  padding: 4px;
  border: 1px solid var(--v2-line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.v2p-variants .variant-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.v2p-variants .variant-btn.is-text {
  width: auto;
  min-width: 64px;
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--v2-ink);
  font-family: var(--v2-font);
  font-size: 13px;
  font-weight: 500;
}

.v2p-variants .variant-btn:hover {
  border-color: #b9b9c0;
}

.v2p-variants .variant-btn.active {
  border-color: var(--v2-ink);
  box-shadow: inset 0 0 0 1px var(--v2-ink);
}

.v2p-variants .variant-btn.is-out {
  opacity: 0.55;
}

.v2p-variants .variant-btn.is-out::after {
  content: "";
  position: absolute;
  inset: 50% 8px auto;
  height: 1px;
  background: #9a9aa1;
  transform: rotate(-20deg);
}

/* Presentaciones como botones */
.v2p-pres {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.v2p-pres-loading {
  grid-column: 1 / -1;
  color: var(--v2-muted);
  font-size: 13px;
}

.v2p-pres-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--v2-line);
  border-radius: 14px;
  background: #fff;
  color: var(--v2-ink);
  font-family: var(--v2-font);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.v2p-pres-opt:hover:not(:disabled) {
  border-color: #b9b9c0;
}

.v2p-pres-opt.is-selected {
  border-color: var(--v2-ink);
  box-shadow: inset 0 0 0 1px var(--v2-ink);
}

.v2p-pres-opt:disabled {
  background: var(--v2-soft);
  color: var(--v2-muted);
  cursor: not-allowed;
}

.v2p-pres-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2p-pres-price {
  color: var(--v2-muted);
  font-size: 12px;
}

.v2p-pres-stock {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
}

.v2p-pres-stock.nivel-bajo {
  color: #c2410c;
}

.v2p-pres-stock.nivel-agotado {
  color: var(--v2-muted);
}

/* Sin stock */
.v2p-out {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--v2-soft);
  font-size: 13px;
  line-height: 1.45;
}

.v2p-out strong {
  display: block;
  margin-bottom: 2px;
  color: var(--v2-ink);
  font-size: 14px;
}

.v2p-out span {
  color: var(--v2-muted);
}

/* Acciones */
.v2p-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.v2p-add,
.v2p-ask {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--v2-ink);
  color: #fff;
  font-family: var(--v2-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.v2p-add:hover {
  background: #000;
}

.v2p-ask {
  background: #1f9d55;
}

.v2p-ask:hover {
  background: #178046;
}

.v2p-icon-btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 1px solid #d6d6db;
  border-radius: 50%;
  background: #fff;
  color: var(--v2-ink);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.v2p-icon-btn:hover {
  border-color: var(--v2-ink);
}

.v2p-icon-btn.btn-favorito {
  color: var(--v2-accent);
}

/* Descripción y ficha */
.v2p-desc,
.v2p-specs {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--v2-line);
}

.v2p-desc[hidden],
.v2p-specs[hidden] {
  display: none;
}

.v2p-desc + .v2p-specs {
  margin-top: 22px;
}

.v2p-subtitle {
  margin: 0 0 10px;
  color: var(--v2-ink);
  font-size: 15px;
  font-weight: 600;
}

.v2p-desc .detalle-descripcion-wrapper {
  --desc-lines: 8;
}

.v2p-desc .detalle-descripcion {
  position: relative;
  margin: 0;
  color: #4a4a50;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}

/* Formato que la tienda puede poner en la descripción */
.v2p-desc .detalle-descripcion :where(b, strong) {
  color: var(--v2-ink);
  font-weight: 600;
}

.v2p-desc .detalle-descripcion :where(p) {
  margin: 0;
}

.v2p-desc .detalle-descripcion :where(ul, ol) {
  margin: 0;
  padding-left: 20px;
  white-space: normal;
}

.v2p-desc .detalle-descripcion.is-collapsed {
  max-height: calc(1.6em * var(--desc-lines));
  overflow: hidden;
}

.v2p-desc .detalle-descripcion.is-collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3em;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff);
  pointer-events: none;
}

.v2p-desc .descripcion-toggle {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--v2-ink);
  font-family: var(--v2-font);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(29, 29, 31, 0.3);
  text-underline-offset: 3px;
  cursor: pointer;
}

.v2p-desc .descripcion-toggle.is-hidden {
  display: none;
}

.v2p-specs-list {
  margin: 0;
}

.v2p-specs-list > div {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 12px;
  padding: 10px 0;
  font-size: 13px;
}

.v2p-specs-list > div + div {
  border-top: 1px solid var(--v2-line);
}

.v2p-specs-list dt {
  color: var(--v2-muted);
}

.v2p-specs-list dd {
  margin: 0;
  color: var(--v2-ink);
  font-weight: 500;
}

/* ── Barra fija en móvil ──────────────────── */

.v2p-sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 28px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--v2-line);
  background: rgba(255, 255, 255, 0.97);
  font-family: var(--v2-font);
  transform: translateY(110%);
  transition: transform 0.25s ease;
}

.v2p-sticky.is-visible {
  transform: none;
}

.v2p-sticky-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 6px;
  min-width: 0;
}

.v2p-sticky-price .precio,
.v2p-sticky-price .precio-oferta {
  color: var(--v2-ink);
  font-size: 17px;
  font-weight: 700;
}

.v2p-sticky-price .precio-original {
  color: var(--v2-muted);
  font-size: 12px;
  text-decoration: line-through;
}

.v2p-sticky-price .descuento-badge {
  display: none;
}

.v2p-sticky .v2-btn {
  flex-shrink: 0;
  height: 44px;
  padding: 0 20px;
}

/* Con la barra a la vista, el aviso sale por encima de ella */
body:has(.v2p-sticky.is-visible) .cart-toast {
  bottom: calc(80px + env(safe-area-inset-bottom));
}

/* ── Relacionados ─────────────────────────── */

.v2p-related {
  margin-top: 40px;
}

/* ── Breakpoints ─────────────────────────── */

@media (min-width: 700px) {
  .v2p-name {
    font-size: 26px;
  }

  .v2p-pres {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .v2p-crumbs {
    margin: 22px 0 22px;
  }

  .v2p-layout {
    grid-template-columns: minmax(0, 11fr) minmax(0, 9fr);
    gap: 48px;
    align-items: start;
  }

  /* Galería: miniaturas a la izquierda, imagen fija mientras se lee la info */
  .v2p-gallery {
    position: sticky;
    top: 86px;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
  }

  .v2p-stage {
    grid-column: 2;
    grid-row: 1;
    border-radius: 26px;
  }

  .v2p-stage .carousel-control {
    display: inline-flex;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .v2p-stage:hover .carousel-control {
    opacity: 1;
  }

  .carousel-thumbs {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    gap: 10px;
  }

  .carousel-thumbs.is-hidden {
    display: none;
  }

  .v2p-gallery:has(.carousel-thumbs.is-hidden) {
    grid-template-columns: minmax(0, 1fr);
  }

  .v2p-gallery:has(.carousel-thumbs.is-hidden) .v2p-stage {
    grid-column: 1;
  }

  .carousel-thumb {
    width: 72px;
    height: 72px;
    padding: 6px;
    border: 1px solid var(--v2-line);
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
  }

  .carousel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .carousel-thumb.active {
    border-color: var(--v2-ink);
  }

  .v2p-info {
    padding-top: 6px;
  }

  .v2p-name {
    font-size: 30px;
  }

  .v2p-price .precio,
  .v2p-price .precio-oferta {
    font-size: 30px;
  }

  .v2p-sticky {
    display: none;
  }

  .v2p-related {
    margin-top: 72px;
  }
}
