/* ── MODAL.CSS ─────────────────────────────────────────────────────────────────
   Modal de detalle de producto y galería full-screen — mismo estilo que
   el proyecto de referencia, adaptado a Herramientas ROHI.
────────────────────────────────────────────────────────────────────────────── */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse-green { 0%,100% { box-shadow: 0 0 0 0 rgba(22,163,74,.4);} 50% { box-shadow: 0 0 0 5px rgba(22,163,74,0);} }
@keyframes pulse-yellow { 0%,100% { box-shadow: 0 0 0 0 rgba(217,119,6,.4);} 50% { box-shadow: 0 0 0 5px rgba(217,119,6,0);} }
@keyframes pulse-blue { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.4);} 50% { box-shadow: 0 0 0 5px rgba(37,99,235,0);} }

.hidden { display: none !important; }

/* ── OVERLAY / SHELL ── */
.modal-product {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .2s ease;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.modal-shell {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 900px;
  max-height: 94vh;    /* fallback */
  max-height: 94dvh;   /* moderno */
  overflow-y: auto;
  position: relative;
  box-shadow: none;
  animation: slideUp .25s ease;
  z-index: 1;
}

.modal-product:not(.hidden) .modal-shell {
  box-shadow: var(--shadow-lg);
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  background: #dc2626;
  border: 2px solid #b91c1c;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  transition: all .15s;
  box-shadow: 0 2px 12px rgba(220, 38, 38, 0.4);
}

.modal-close-btn:hover {
  background: #b91c1c;
  transform: scale(1.08);
}

/* ── LAYOUT INTERIOR ── */
.modal-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 480px;
}

.modal-img-side {
  background: var(--bg);
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── IMAGEN PRINCIPAL ── */
.modal-main-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  background: linear-gradient(135deg, #f8f9fc, #eef1f8);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}

.modal-main-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  padding: 16px;
  user-select: none;
  pointer-events: none;
  transition: opacity .2s ease;
}

.modal-no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  opacity: .2;
}

.modal-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 8px;
  pointer-events: none;
  z-index: 10;
}

.gallery-arrow {
  pointer-events: all;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 0, 0, 0.1);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
  transition: all .15s;
  flex-shrink: 0;
}

.gallery-arrow:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.08);
}

.modal-gallery-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: 50px;
  font-size: 11px;
  padding: 4px 12px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

/* ── MINIATURAS DEL MODAL ── */
.modal-thumbs {
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-thumb {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid transparent;
  transition: all .15s;
  opacity: .6;
  padding: 4px;
}

.modal-thumb:hover { opacity: 1; }
.modal-thumb.active { border-color: var(--accent); opacity: 1; }

/* ── LADO INFO ── */
.modal-info-side {
  padding: 28px 26px;
}

.modal-cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}

.modal-cat-tag svg { width: 14px; height: 14px; }

.modal-prod-brand {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 5px;
}

.modal-prod-name {
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: -0.2px;
  margin-bottom: 14px;
}

.modal-prod-price {
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 12px;
}

.modal-prod-price sup {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink3);
}

.modal-prod-desc {
  font-size: 14px;
  color: var(--ink2);
  line-height: 1.7;
  margin-bottom: 18px;
  white-space: pre-line;
}

/* ── BADGE DE ESTADO ── */
.modal-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 50px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 800;
  margin-bottom: 16px;
  border: 2px solid transparent;
}

.modal-status-badge .status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.modal-status-badge.badge-disponible { background: #dcfce7; color: #15803d; border-color: #86efac; }
.modal-status-badge.badge-disponible .status-dot { background: #16a34a; animation: pulse-green 1.5s infinite; }

.modal-status-badge.badge-pocas { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.modal-status-badge.badge-pocas .status-dot { background: #d97706; animation: pulse-yellow 1.5s infinite; }

.modal-status-badge.badge-agotado { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.modal-status-badge.badge-agotado .status-dot { background: #dc2626; }

.modal-status-badge.badge-proximamente { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.modal-status-badge.badge-proximamente .status-dot { background: #2563eb; animation: pulse-blue 1.5s infinite; }

/* ── AVISOS ── */
.agotado-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff5f5;
  border: 2px solid #fca5a5;
  border-radius: 15px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.agotado-notice-icon { font-size: 20px; flex-shrink: 0; }

.agotado-notice-text strong {
  display: block;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 800;
  color: #b91c1c;
  margin-bottom: 3px;
}

.agotado-notice-text p {
  font-size: 13px;
  color: #dc2626;
  line-height: 1.5;
}

.modal-store-note {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

/* ── LÍNEA DE TIENDA DISPONIBLE ── */
.modal-store-line {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--green-s, rgba(22,163,74,.08));
  border: 1px solid rgba(22,163,74,.2);
  border-radius: 15px;
  padding: 11px 14px;
  font-size: 12.5px;
  color: #065f46;
  line-height: 1.5;
}

.store-line-title {
  font-weight: 600;
}

.store-line-title strong {
  font-weight: 800;
  color: #065f46;
}

.store-line-address {
  font-size: 12px;
  color: #047857;
  opacity: .9;
}

/* ── LÍNEA DE TIENDA NO DISPONIBLE ── */
.modal-store-line.no-disponible {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.modal-store-line.no-disponible .store-line-title strong {
  color: #b91c1c;
}

/* ── BOTÓN WHATSAPP ── */
.btn-whatsapp-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 18px;
  transition: all .15s;
}

.btn-whatsapp-modal svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-whatsapp-modal:hover {
  background: #20b858;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp-modal:not(:disabled):not(.disabled):hover {
  background: #20b858;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp-modal:disabled,
.btn-whatsapp-modal.disabled,
.btn-whatsapp-modal:disabled:hover,
.btn-whatsapp-modal.disabled:hover {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── ESPECIFICACIONES ── */
.specs-section-modal {
  margin-bottom: 6px;
  padding-right: 4px;
}

.specs-section-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink4);
  margin-bottom: 10px;
}

.specs-table {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 7px;
}

.spec-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.spec-cell-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink4);
  margin-bottom: 2px;
}

.spec-cell-val {
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: pre-line;   /* ✅ respeta los saltos de línea del admin */
  overflow-wrap: anywhere; /* evita desbordes con palabras muy largas */
}

.specs-empty { font-size: 13px; color: var(--ink3); grid-column: 1/-1; }

/* ── GALERÍA FULL-SCREEN ── */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}

.gallery-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

.gallery-close-btn { top: 20px; right: 20px; }

.gallery-modal-img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  padding: 0 20px;
}

.gallery-modal-img {
  max-width: 100%;
  max-height: 70vh;    /* fallback */
  max-height: 70dvh;   /* moderno */
  object-fit: contain;
  border-radius: var(--radius-lg);
}

.gallery-arrow-lg {
  width: 48px;
  height: 48px;
  font-size: 24px;
  background: rgba(255,255,255,.12);
  border: 2px solid rgba(255,255,255,.2);
  color: #fff;
  backdrop-filter: blur(6px);
}
.gallery-arrow-lg:hover { background: rgba(255,255,255,.25); border-color: rgba(255,255,255,.4); }

/* ── DOTS OCULTOS ── */
.gallery-modal-dots {
  display: none !important;
}

/* ── MINIATURAS DE LA GALERÍA FULL-SCREEN ── */
.gallery-modal-thumbs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.gallery-modal-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: rgba(255,255,255,.1);
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.45;
  padding: 3px;
  transition: opacity .2s ease, border-color .2s ease, transform .2s ease;
}

.gallery-modal-thumb:hover {
  opacity: 0.75;
}

.gallery-modal-thumb.active {
  border-color: #fff;
  opacity: 1;
  transform: scale(1.05);
}

/* ── RESPONSIVE ── */
@media (max-width: 760px) {
  .modal-content { grid-template-columns: 1fr; }
  .modal-img-side { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-shell {
    max-height: 96vh;    /* fallback */
    max-height: 96dvh;   /* moderno */
  }
}

/* ── GALERÍA FULL-SCREEN: flechas a los lados de la imagen (móvil) ── */
.gallery-modal-img {
  min-width: 0;       /* deja que la imagen se encoja dentro del flex */
  flex: 0 1 auto;
}

@media (max-width: 768px) {
  .gallery-modal-img-wrap {
    gap: 8px;
    padding: 0 8px;
  }

  .gallery-modal-img {
    height: auto;
    background: #fff;
    border-radius: var(--radius-md, 12px);
  }

  .gallery-arrow-lg {
    flex-shrink: 0;   /* las flechas nunca se aplastan ni se salen */
    width: 28px;
    height: 28px;
    font-size: 14px;
    background: rgba(60, 60, 60, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    backdrop-filter: none;
  }

  .gallery-arrow-lg:hover {
    transform: none;
    background: rgba(60, 60, 60, 0.9);
    border-color: rgba(255, 255, 255, 0.25);
  }
}

/* ── UN SOLO SCROLL: el del modal ── */
.modal-shell {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Bloquea el scroll de la página mientras el modal está abierto */
body:has(.modal-product:not(.hidden)),
body:has(.gallery-modal:not(.hidden)) {
  overflow: hidden;
}