/* =======================
   detalle iPhone 17 - CSS
   Encapsulado para evitar choques
   ======================= */

/* Variables y layout general de la página */
:root {
  --nav-h: 92px; /* ajusta si tu navbar es más alto */
  --footer-h: 340px; /* ajusta según tu footer real */
  --wrap-w: 1100px;
  --gap: 28px;
  --r-lg: 24px;
  --r-md: 16px;

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-bd: rgba(255, 255, 255, 0.2);
  --glass-bg-strong: rgba(255, 255, 255, 0.16);
  --glass-bd-strong: rgba(255, 255, 255, 0.28);
  --text-muted: rgba(255, 255, 255, 0.8);
}

/* Empuja el footer al fondo sin "página larga" */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.detalle-wrap {
  flex: 1;
}

/* ---------- Contenedor principal ---------- */
/* columna de imagen más ancha y alta */
.detalle-wrap {
  width: min(var(--wrap-w), 92%);
  margin: calc(var(--nav-h) + 24px) auto 24px;
  display: grid;
  grid-template-columns: 720px 1fr; /* ancho real para la foto */
  gap: var(--gap);
  border-radius: var(--r-lg);
  padding: 24px;
  position: relative;
  overflow: visible;
}
.detalle-media {
  min-height: 680px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
}
.detalle-media img {
  display: block;
  max-width: 100%;
  max-height: 680px;
  width: auto;
  height: auto;
  object-fit: contain;
}
@media (max-width: 1100px) {
  .detalle-wrap {
    grid-template-columns: 520px 1fr;
  }
  .detalle-media {
    min-height: 520px;
  }
  .detalle-media img {
    max-height: 520px;
  }
}
.detalle-wrap {
  grid-template-columns: 520px 1fr;
}
.detalle-media {
  min-height: 520px;
}
.detalle-media img {
  max-height: 520px;
}

/* Base glass por si tu tema no lo aplica aquí */
.detalle-wrap.glass-effect {
  background: var(--glass-bg);
  border: 1px solid var(--glass-bd);
  backdrop-filter: blur(12px) saturate(140%);
}

/* Hover "glass glow" de todo el bloque */
.detalle-wrap:hover {
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

/* ---------- Columna de info ---------- */
.detalle-info {
  display: grid;
  gap: 14px;
  align-content: start;
}
.detalle-title {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.2px;
}

/* ---------- Paneles ---------- */
.detalle-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-bd);
  backdrop-filter: blur(12px) saturate(140%);
  border-radius: var(--r-md);
  padding: 16px;
  position: relative;
  isolation: isolate;
  z-index: 1;
}
.detalle-label {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 8px;
  opacity: 0.95;
}
.detalle-help {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.detalle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px; /* respiración uniforme */
  position: relative;
  z-index: 4;
}

/* ---------- Normalización de botones sólo dentro de la detalle ---------- */
.detalle-wrap button {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0; /* evita padding por defecto que deforma los swatches */
}

/* ---------- Swatches de color ---------- */
/* Usar variable CSS --c para colores dinámicos */
.detalle-swatch {
  width: 20px;
  height: 20px;
  aspect-ratio: 1/1;
  display: inline-block;
  flex: 0 0 auto;
  line-height: 0;
  border-radius: 50%;
  background: var(--c, #9ca3af);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* Soporte para colores hardcodeados (fallback) */
.detalle-swatch[data-color="White"],
.detalle-swatch[data-color="white"],
.detalle-swatch[data-color="Blanco"],
.detalle-swatch[data-color="blanco"] {
  background: #f2f2f2;
}

.detalle-swatch[data-color="Black"],
.detalle-swatch[data-color="black"],
.detalle-swatch[data-color="Negro"],
.detalle-swatch[data-color="negro"] {
  background: #0b0b0c;
}

.detalle-swatch[data-color="Blue"],
.detalle-swatch[data-color="blue"],
.detalle-swatch[data-color="Azul"],
.detalle-swatch[data-color="azul"] {
  background: #3b82f6;
}

.detalle-swatch[data-color="ultramarine"],
.detalle-swatch[data-color="Ultramarine"] {
  background: #5a7acd;
}

.detalle-swatch[data-color="Pink"],
.detalle-swatch[data-color="pink"],
.detalle-swatch[data-color="Rosa"],
.detalle-swatch[data-color="rosa"] {
  background: #ff80ab;
}

.detalle-swatch[data-color="Teal"],
.detalle-swatch[data-color="teal"],
.detalle-swatch[data-color="Verde Agua"],
.detalle-swatch[data-color="verde agua"] {
  background: #10b981;
}

.detalle-swatch[data-color="Green"],
.detalle-swatch[data-color="green"],
.detalle-swatch[data-color="Verde"],
.detalle-swatch[data-color="verde"] {
  background: #22c55e;
}

.detalle-swatch[data-color="Red"],
.detalle-swatch[data-color="red"],
.detalle-swatch[data-color="Rojo"],
.detalle-swatch[data-color="rojo"] {
  background: #ef4444;
}

.detalle-swatch[data-color="Yellow"],
.detalle-swatch[data-color="yellow"],
.detalle-swatch[data-color="Amarillo"],
.detalle-swatch[data-color="amarillo"] {
  background: #fbbf24;
}

.detalle-swatch[data-color="Purple"],
.detalle-swatch[data-color="purple"],
.detalle-swatch[data-color="Purpura"],
.detalle-swatch[data-color="purpura"],
.detalle-swatch[data-color="Púrpura"],
.detalle-swatch[data-color="púrpura"] {
  background: #a855f7;
}

.detalle-swatch[data-color="Gray"],
.detalle-swatch[data-color="gray"],
.detalle-swatch[data-color="Gris"],
.detalle-swatch[data-color="gris"] {
  background: #6b7280;
}

.detalle-swatch[data-color="Silver"],
.detalle-swatch[data-color="silver"],
.detalle-swatch[data-color="plata"],
.detalle-swatch[data-color="Plata"] {
  background: #99a0ae;
}

.detalle-swatch[data-color="Gold"],
.detalle-swatch[data-color="gold"],
.detalle-swatch[data-color="Oro"],
.detalle-swatch[data-color="oro"] {
  background: #d4af37;
}

.detalle-swatch[data-color="Orange"],
.detalle-swatch[data-color="orange"],
.detalle-swatch[data-color="Naranja"],
.detalle-swatch[data-color="naranja"] {
  background: #f97316;
}

.detalle-swatch[data-color="Lavander"] {
  background: #8c00ff;
}
.detalle-swatch[data-color="Desert"] {
  background: #ffe797;
}
.detalle-swatch[data-color="Mid"] {
  background: #132440;
}
.detalle-swatch[data-color="Midnight"] {
  background: #132440;
}
.detalle-swatch[data-color="Graphito"] {
  background: #7a7a73;
}
.detalle-swatch[data-color="Star"] {
  background: #f6f6f6;
}
.detalle-swatch:hover {
  transform: translateY(-2px);
}
.detalle-swatch.is-active {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35),
    0 0 22px rgba(255, 255, 255, 0.18);
}

/* ampliar zona de click sin cambiar lo visual */
.detalle-swatch {
  position: relative;
}
.detalle-swatch::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 18px;
}

/* ---------- Opciones (capacidad y qty) ---------- */
.detalle-opt {
  min-width: 80px; /* ancho fijo y parejo */
  height: 44px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 900;
  border: 1px solid var(--glass-bd-strong);
  background: var(--glass-bg-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  position: relative;
}
.detalle-opt:hover:not(:disabled) {
  transform: translateY(-2px);
}
.detalle-opt.is-active {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28),
    0 0 22px rgba(255, 255, 255, 0.18);
}

/* Cantidad */
.detalle-qty {
  align-items: center;
  gap: 16px;
}
.detalle-qty .detalle-opt {
  min-width: 50px;
  width: 20px;
  height: 20px;
  font-size: 1.5rem;
  font-weight: 700;
}
.detalle-qty #qty {
  min-width: 3ch;
  text-align: center;
  font-weight: 900;
  font-size: 1.3rem;
}

/* ---------- Wrapper de Cantidad + Botones ---------- */
.detalle-actions-wrapper {
  display: flex;
  align-items: stretch;
  gap: 16px;
}

/* Panel de cantidad cuadrado y centrado */
.detalle-qty-panel {
  flex: 0 0 auto;
  width: 200px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 16px 12px 12px 12px;
  position: relative;
  z-index: 1;
}

.detalle-qty-panel .detalle-label {
  text-align: center;
  width: 100%;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.detalle-qty-panel .detalle-row {
  justify-content: center;
  position: relative;
  z-index: 5;
  margin-bottom: 10px;
}

.detalle-qty-panel .detalle-help {
  text-align: center;
  width: 100%;
  font-size: 0.85rem;
  line-height: 1.8;
  margin-top: 10px;
  margin-bottom: 5px;
}

/* Asegurar que los botones de cantidad sean clickeables */
.detalle-qty-panel .detalle-opt {
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}

/* Grupo de botones al lado */
.detalle-buttons-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
}

/* ---------- Precio + Resumen ---------- */
.detalle-price-section {
  margin-top: 8px;
  display: flex;
  align-items: center;
  margin-left: 25px;
  justify-content: space-between;
  gap: 20px;
}

.detalle-price {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  margin: 0;
  flex-shrink: 0;
}

.detalle-small {
  font-size: 0.95rem;
  opacity: 0.85;
  text-align: right;
  flex: 1;
}

.detalle-small #sumCondicion {
  opacity: 0.9;
  font-weight: 600;
}

/* Botón principal */
.detalle-btn {
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.16);
  font-weight: 900;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s,
    border-color 0.2s;
}
.detalle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35),
    0 0 34px rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.42);
}
.detalle-btn.primary {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.28),
    rgba(255, 255, 255, 0.16)
  );
}

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .detalle-wrap {
    grid-template-columns: 460px 1fr;
  }
  .detalle-media {
    min-height: 480px;
  }
  .detalle-media img {
    max-height: 480px;
  }
}
@media (max-width: 980px) {
  .detalle-wrap {
    grid-template-columns: 1fr;
  }
  .detalle-media {
    min-height: 420px;
  }
  .detalle-media img {
    max-height: 420px;
  }

  /* Cambiar a layout vertical en móvil */
  .detalle-actions-wrapper {
    flex-direction: column;
  }

  .detalle-qty-panel {
    width: 100%;
    min-width: auto;
  }

  .detalle-buttons-group {
    width: 100%;
  }
}

/* ---------- Accesibilidad: respeta reduce motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .detalle-wrap * {
    transition: none !important;
  }
}

/* Fade suave al cambiar la foto */
.detalle-media img {
  transition: opacity 0.25s ease;
}

/* Mejor foco teclado */
.detalle-swatch:focus-visible,
.detalle-opt:focus-visible,
.detalle-btn:focus-visible {
  outline: 2px solid #fff8;
  outline-offset: 2px;
}

/* Tipografía y separación más uniforme en los "cuadrados" */
.detalle-opt {
  letter-spacing: 0.2px;
}
.detalle-row {
  gap: 14px;
}

/* Botones deshabilitados */
.detalle-opt:disabled,
.detalle-swatch:disabled {
  cursor: not-allowed;
  opacity: 0.3;
  filter: grayscale(0.5);
}

.detalle-opt:disabled:hover,
.detalle-swatch:disabled:hover {
  transform: none;
}

.detalle-opt:disabled.is-active,
.detalle-swatch:disabled.is-active {
  background: var(--glass-bg-strong);
  box-shadow: none;
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Asegurar overflow */
body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.detalle-wrap {
  max-width: 100%;
  box-sizing: border-box;
}

/* Tablets (768px - 900px) */
@media (max-width: 900px) {
  .detalle-wrap {
    grid-template-columns: 1fr;
    width: min(var(--wrap-w), 95%);
    margin-top: calc(var(--nav-h) + 16px);
    padding: 18px;
    gap: 20px;
  }

  .detalle-media {
    min-height: 400px;
    max-height: 500px;
  }

  .detalle-media img {
    max-height: 400px;
  }

  .detalle-info {
    gap: 12px;
  }

  .detalle-title {
    font-size: 1.8rem !important;
  }

  .detalle-price {
    font-size: 1.6rem !important;
  }

  .detalle-row {
    gap: 10px;
  }

  .detalle-opt,
  .detalle-swatch {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
}

/* Móviles (480px - 768px) */
@media (max-width: 768px) {
  :root {
    --nav-h: 70px;
    --gap: 16px;
  }

  .detalle-wrap {
    width: min(100%, 96%);
    margin-top: calc(var(--nav-h) + 12px);
    padding: 14px;
    gap: 16px;
  }

  .detalle-media {
    min-height: 320px;
    max-height: 400px;
  }

  .detalle-media img {
    max-height: 320px;
  }

  .detalle-title {
    font-size: 1.5rem !important;
    margin-bottom: 8px !important;
  }

  .detalle-price {
    font-size: 1.4rem !important;
    padding: 10px 16px !important;
  }

  .detalle-desc {
    font-size: 0.95rem !important;
    line-height: 1.4 !important;
  }

  .detalle-row {
    gap: 8px;
    flex-wrap: wrap;
  }

  .detalle-opt,
  .detalle-swatch {
    padding: 8px 14px;
    font-size: 0.85rem;
    min-width: 60px;
  }

  .detalle-actions {
    gap: 10px;
    flex-direction: column;
  }

  .detalle-btn {
    width: 100% !important;
    padding: 12px 20px !important;
    font-size: 0.95rem !important;
  }
}

/* Móviles pequeños (< 480px) */
@media (max-width: 480px) {
  :root {
    --nav-h: 60px;
    --gap: 12px;
  }

  .detalle-wrap {
    width: min(100%, 98%);
    margin-top: calc(var(--nav-h) + 10px);
    padding: 12px;
    gap: 12px;
    border-radius: 16px;
  }

  .detalle-media {
    min-height: 280px;
    max-height: 350px;
    border-radius: 14px;
  }

  .detalle-media img {
    max-height: 280px;
  }

  .detalle-info {
    gap: 10px;
  }

  .detalle-title {
    font-size: 1.3rem !important;
    margin-bottom: 6px !important;
    line-height: 1.2 !important;
  }

  .detalle-price {
    font-size: 1.2rem !important;
    padding: 8px 14px !important;
  }

  .detalle-desc {
    font-size: 0.9rem !important;
    line-height: 1.4 !important;
  }

  .detalle-label {
    font-size: 0.85rem !important;
    margin-bottom: 6px !important;
  }

  .detalle-row {
    gap: 6px;
    flex-wrap: wrap;
  }

  .detalle-opt,
  .detalle-swatch {
    padding: 7px 12px;
    font-size: 0.8rem;
    min-width: 55px;
  }

  .detalle-swatch {
    width: 36px;
    height: 36px;
  }

  .detalle-actions {
    gap: 8px;
    flex-direction: column;
    margin-top: 12px;
  }

  .detalle-btn {
    width: 100% !important;
    padding: 11px 18px !important;
    font-size: 0.9rem !important;
  }
}

/* Móviles muy pequeños (< 360px) */
@media (max-width: 360px) {
  .detalle-wrap {
    width: 100%;
    margin-top: calc(var(--nav-h) + 8px);
    padding: 10px;
    gap: 10px;
  }

  .detalle-media {
    min-height: 240px;
    max-height: 300px;
  }

  .detalle-media img {
    max-height: 240px;
  }

  .detalle-title {
    font-size: 1.2rem !important;
  }

  .detalle-price {
    font-size: 1.1rem !important;
    padding: 7px 12px !important;
  }

  .detalle-desc {
    font-size: 0.85rem !important;
  }

  .detalle-opt,
  .detalle-swatch {
    padding: 6px 10px;
    font-size: 0.75rem;
    min-width: 50px;
  }

  .detalle-swatch {
    width: 32px;
    height: 32px;
  }
}
