/* ==========================================================================
   css/product.css — Detalle del producto (modal y página directa)
   Depende de css/style.css
   ========================================================================== */

/* ── Modal (<dialog>) ───────────────────────────────────────────────────── */
.product-modal {
  border: none;
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 1000px;
  width: 94vw;
  max-height: 90vh;
  margin: auto;
  background: white;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  position: relative;
}

.product-modal::backdrop {
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Animación de apertura */
@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(20px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.product-modal[open] {
  animation: modalIn .28s cubic-bezier(.16, 1, .3, 1) forwards;
}

/* Contenedor con scroll */
.product-modal-inner {
  overflow-y: auto;
  max-height: 90vh;
  /* padding-top para compensar el botón cerrar absoluto */
  padding-top: 0;
}

/* ── Botón cerrar ────────────────────────────────────────────────────────── */
.modal-close-btn {
  position: absolute;
  top: .9rem; right: .9rem;
  z-index: 20;
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.92);
  color: var(--text-main);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all var(--t-fast);
  border: none; cursor: pointer;
}
.modal-close-btn:hover { background: var(--text-main); color: white; }

/* ── Layout del detalle (2 columnas en desktop) ───────────────────────────── */
.product-modal-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 420px;
}

/* ── Galería ─────────────────────────────────────────────────────────────── */
.product-gallery {
  background: var(--bg-muted);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.gallery-main {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: white;
  aspect-ratio: 1/1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}

.gallery-main-img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity .18s ease-in-out;
  will-change: opacity;
}

.gallery-no-img {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .6rem; color: var(--text-light);
  font-size: .85rem; width: 100%; height: 100%;
}

.gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.gallery-thumb {
  width: 60px; height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  background: white;
  cursor: pointer;
  transition: all var(--t-fast);
  padding: 0; flex-shrink: 0;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb:hover { border-color: var(--border-hover); }
.gallery-thumb.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.2); }

/* ── Columna de detalles ────────────────────────────────────────────────── */
.product-detail-col {
  padding: 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-meta-top {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.detail-category {
  font-size: .78rem; font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: .2rem .6rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stock-badge {
  font-size: .78rem; font-weight: 700;
  padding: .22rem .65rem;
  border-radius: var(--radius-full);
}
.stock-badge.in-stock     { background: var(--success-light); color: #065f46; }
.stock-badge.out-of-stock { background: var(--danger-light);  color: #991b1b; }

.detail-title {
  font-size: 1.55rem; font-weight: 800;
  line-height: 1.2; letter-spacing: -.02em;
  color: var(--text-main);
}

.detail-short-desc {
  font-size: .9rem; color: var(--text-muted); line-height: 1.5;
}

.detail-price-row { display: flex; align-items: baseline; gap: .6rem; }

.detail-price {
  font-size: 2rem; font-weight: 800;
  color: var(--primary);
  transition: color .15s;
}

/* ── Selector de opciones ────────────────────────────────────────────────── */
.detail-options { display: flex; flex-direction: column; gap: .5rem; }

.detail-option-label {
  font-size: .85rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
}

.option-values-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.option-value-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .55rem .85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  min-width: 72px; text-align: center;
  background: var(--bg-card);
}
.option-value-label input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.option-value-label:hover:not(.out-of-stock) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.option-value-label.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.option-value-label.out-of-stock {
  opacity: .45; cursor: not-allowed; text-decoration: line-through;
}

.option-value-name  { font-size: .9rem; font-weight: 700; color: var(--text-main); }
.option-value-price { font-size: .78rem; color: var(--primary); font-weight: 600; }

/* ── Fila compra: cantidad + botón ───────────────────────────────────────── */
.detail-buy-row {
  display: flex;
  align-items: stretch;
  gap: .75rem;
  flex-wrap: wrap;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  overflow: hidden;
}
.btn-qty {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: white; color: var(--text-main);
  transition: all var(--t-fast);
  border: none; cursor: pointer;
}
.btn-qty:hover:not(:disabled) { background: var(--primary-light); color: var(--primary); }
.btn-qty:disabled { opacity: .35; cursor: not-allowed; }

.qty-input {
  width: 46px; height: 38px;
  text-align: center; border: none;
  background: var(--bg-muted);
  font-weight: 700; font-size: .95rem;
  color: var(--text-main);
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.btn-add-to-cart {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--primary); color: white;
  padding: .65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 700; font-size: .95rem;
  transition: all var(--t-fast);
  cursor: pointer; border: none;
  min-height: 38px;
}
.btn-add-to-cart:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,.3);
}
.btn-add-to-cart:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Tiempo de producción ────────────────────────────────────────────────── */
.detail-prod-time {
  display: flex; align-items: center; gap: .4rem;
  font-size: .82rem; color: var(--text-muted);
  background: var(--bg-muted);
  padding: .4rem .75rem;
  border-radius: var(--radius-sm);
}

/* ── Atributos ───────────────────────────────────────────────────────────── */
.detail-section-title {
  font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.attrs-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.attrs-table tr { border-bottom: 1px solid var(--border); }
.attrs-table tr:last-child { border-bottom: none; }
.attrs-table td { padding: .45rem .3rem; }
.attr-name { font-weight: 600; color: var(--text-muted); width: 40%; }
.attr-value { color: var(--text-main); }
.attr-unit { font-size: .78rem; color: var(--text-light); margin-left: .25rem; }

/* ── Descripción larga ───────────────────────────────────────────────────── */
.detail-description {
  font-size: .88rem; line-height: 1.65; color: var(--text-main);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.detail-description p { margin-bottom: .6rem; }
.detail-description ul, .detail-description ol { padding-left: 1.25rem; }
.detail-description li { margin-bottom: .3rem; }

/* ── Preguntas rápidas ───────────────────────────────────────────────────── */
.detail-quick-questions {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.quick-q-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .75rem;
}

.quick-q-btn {
  padding: .38rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: .82rem; font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  cursor: pointer; transition: all var(--t-fast);
}
.quick-q-btn:hover, .quick-q-btn.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.quick-q-panel {
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: .75rem;
  font-size: .88rem;
  margin-bottom: .75rem;
  display: none;
}
.quick-q-panel.visible { display: block; }
.quick-q-selected-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.btn-whatsapp-doubt-inline {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .75rem;
  background: #25d366;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-whatsapp-doubt-inline:hover {
  background: #1ebe5d;
  box-shadow: 0 2px 8px rgba(37,211,102,.25);
}

.quick-q-input {
  width: 100%; padding: .5rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .88rem; margin-top: .4rem;
  background: white;
}
.quick-q-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.btn-whatsapp-doubt {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; padding: .65rem;
  background: #25d366; color: white;
  border: none; border-radius: var(--radius-md);
  font-weight: 700; font-size: .9rem;
  cursor: pointer; transition: all var(--t-fast);
}
.btn-whatsapp-doubt:hover {
  background: #1ebe5d;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,211,102,.3);
}

/* ── Error en modal ──────────────────────────────────────────────────────── */
.modal-error {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
}
.modal-error-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.modal-error h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: .5rem; color: var(--text-main); }
.modal-error p  { margin-bottom: 1.25rem; font-size: .9rem; }
.btn-modal-back {
  display: inline-block; padding: .55rem 1.25rem;
  background: var(--primary); color: white;
  border-radius: var(--radius-full); font-weight: 600; font-size: .88rem;
}

/* ── Cargando (estado HTMX) ─────────────────────────────────────────────── */
.modal-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 300px; gap: 1rem;
  color: var(--text-muted); font-size: .9rem;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Breadcrumb (página directa) ─────────────────────────────────────────── */
.breadcrumb-nav {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: .65rem 0;
}
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: .3rem;
  list-style: none; font-size: .82rem; color: var(--text-muted);
}
.breadcrumb li { display: flex; align-items: center; gap: .3rem; }
.breadcrumb li:not(:last-child)::after { content: '/'; color: var(--border-hover); }
.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Página directa del producto ─────────────────────────────────────────── */
.product-page-section { padding: 2.5rem 0 5rem; }
.product-page-card {
  background: white;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
}

/* ── Preguntas frecuentes (FAQ) ─────────────────────────────────────────── */
.detail-faqs {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.faq-item[open] {
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.faq-question::-webkit-details-marker {
  display: none;
}
.faq-question:hover {
  background: var(--bg-muted);
}
.faq-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--t-fast);
}
.faq-item[open] .faq-icon {
  transform: rotate(180deg);
  color: var(--primary);
}
.faq-answer {
  padding: 0 1rem 0.85rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  margin-top: 0.25rem;
  padding-top: 0.65rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .product-modal { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; margin: auto 0 0; }
  .product-modal-layout { grid-template-columns: 1fr; }
  .product-gallery { padding: 1rem; }
  .gallery-main { aspect-ratio: 4/3; }
  .product-detail-col { padding: 1.25rem; }
  .detail-title { font-size: 1.25rem; }
  .detail-price { font-size: 1.6rem; }

  /* Modal desde abajo en móvil */
  .product-modal::backdrop { align-items: flex-end; }
}

@media (max-width: 480px) {
  .detail-buy-row { flex-direction: column; }
  .btn-add-to-cart { width: 100%; }
  .gallery-thumb { width: 52px; height: 52px; }
}
