/* ═══════════════════════════════════════════════════════════
   modal.css — Modal detail produk
   Editorial · warm · professional
   ═══════════════════════════════════════════════════════════ */

/* ─── Backdrop ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(42,23,20,.68);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 24px;
  opacity: 0; visibility: hidden;
  transition: opacity .24s cubic-bezier(.4,0,.2,1), visibility 0s linear .24s;
  overflow-y: auto;
}
.modal-backdrop.open {
  opacity: 1; visibility: visible;
  transition: opacity .24s cubic-bezier(.4,0,.2,1), visibility 0s linear 0s;
}

/* ─── Shell ────────────────────────────────────────────── */
.modal {
  background: var(--card);
  width: 100%; max-width: 1000px;
  border-radius: 28px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.05),
    0 40px 80px -20px rgba(42,23,20,.45),
    0 20px 40px -20px rgba(160,56,82,.25);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  /* minmax(0,1fr) memaksa grid row setinggi container — tanpa ini,
     grid item bisa meluber melebihi tinggi modal. */
  grid-template-rows: minmax(0, 1fr);
  position: relative;
  transform: translateY(20px) scale(.96);
  transition: transform .32s cubic-bezier(.2,.7,.3,1);
  /* Tinggi FIXED + body scroll internal. Modal selalu sama ukuran
     antar produk — ini yang bikin tenang dan predictable. Konten
     panjang akan di-scroll di dalam body; konten pendek akan punya
     sedikit ruang bernafas di atas action bar (normal, tidak masalah
     selama action bar ada di dasar). */
  height: min(640px, calc(100vh - 64px));
  max-height: calc(100vh - 64px);
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }

/* ─── Close button ─────────────────────────────────────── */
.modal-close {
  position: absolute; top: 18px; right: 18px; z-index: 3;
  width: 40px; height: 40px;
  border-radius: 50%; border: 0;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-size: 20px; line-height: 1; font-weight: 300;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow:
    0 1px 2px rgba(44,26,24,.08),
    0 8px 20px -8px rgba(44,26,24,.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .18s, color .18s, transform .2s cubic-bezier(.4,0,.2,1);
  font-family: var(--font-sans);
}
.modal-close:hover {
  background: var(--brand); color: #fff;
  transform: rotate(90deg) scale(1.05);
}

/* ─── Media panel ──────────────────────────────────────── */
.modal-media {
  position: relative;
  background: var(--bg-warm);
  display: flex; flex-direction: column;
  /* Grid item dibatasi oleh row (minmax). min-height:0 + overflow
     supaya media tidak ikut melar mengikuti konten body. */
  min-height: 0;
  overflow: hidden;
}
.modal-media-main {
  /* Panel gambar mengisi PENUH kolom kiri. Karena modal sudah fixed
     height, min-height tidak perlu — kolom ini pasti setinggi modal. */
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.modal-media-main::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 70%, rgba(42,23,20,.06) 100%);
  pointer-events: none;
}
.modal-media-main img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.modal-media-main img.img-fallback {
  object-fit: contain; padding: 48px;
}

/* Thumbs strip */
.modal-thumbs {
  display: flex; gap: 8px; padding: 12px 14px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(238,221,211,.6);
  overflow-x: auto;
  scrollbar-width: none;
}
.modal-thumbs::-webkit-scrollbar { display: none; }
.modal-thumb {
  flex: 0 0 60px;
  width: 60px; height: 60px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--bg-alt);
  transition: border-color .18s, transform .18s, opacity .18s;
  padding: 0;
  opacity: .7;
}
.modal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.modal-thumb:hover { transform: translateY(-2px); opacity: 1; }
.modal-thumb.active {
  border-color: var(--brand);
  opacity: 1;
  box-shadow: 0 4px 12px -4px rgba(201,86,110,.5);
}

/* ─── Panel kanan (body + actions) ─────────────────────────
   Flex column: body scroll di atas, action bar di bawah.
   Ini yang membuat tombol WA TIDAK ikut scroll.
   ─────────────────────────────────────────────────────── */
.modal-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--card);
}

/* ─── Body panel (scroll area) ─────────────────────────── */
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 52px 44px 28px;
  display: flex; flex-direction: column;
  background: var(--card);
}

/* Kategori — uppercase sans, subtle */
.modal-body .card-kategori {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 14px;
}
.modal-body .card-kategori::before {
  content: ""; width: 18px; height: 1px;
  background: var(--brand); opacity: .6;
}

/* Nama — display besar, hairline di bawah */
.modal-nama {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: -.025em;
  margin: 0 0 16px;
  font-weight: 700;
  color: var(--ink);
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

/* Badge dengan dot */
.modal-badge {
  display: inline-flex; align-items: center; gap: 7px;
  align-self: flex-start;
  font-family: var(--font-sans);
  font-size: .68rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 14px 6px 11px;
  border-radius: 999px;
  margin-bottom: 20px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(201,86,110,.5);
}
.modal-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}
.modal-badge.habis {
  background: var(--ink);
  box-shadow: 0 4px 12px -4px rgba(44,26,24,.4);
}
.modal-badge.preorder {
  background: var(--accent); color: var(--ink);
  box-shadow: 0 4px 12px -4px rgba(229,183,105,.5);
}

/* Deskripsi */
.modal-deskripsi {
  font-size: 1rem; line-height: 1.7;
  color: var(--ink-muted);
  margin: 0 0 26px;
  white-space: pre-line;
}

/* Harga — display editorial tanpa border kaku */
.modal-harga {
  display: flex; align-items: baseline; gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--line);
}
.modal-harga .harga-diskon {
  font-family: var(--font-serif);
  font-size: 2.1rem; font-weight: 700;
  color: var(--brand); letter-spacing: -.02em;
}
.modal-harga .harga-now {
  font-family: var(--font-serif);
  font-size: 2.1rem; font-weight: 700;
  color: var(--ink); letter-spacing: -.02em;
}
.modal-harga .harga-strike {
  font-size: 1rem; color: var(--ink-muted);
  text-decoration: line-through; opacity: .55;
}
.modal-harga .harga-satuan {
  font-size: .88rem;
  color: var(--ink-muted);
  font-family: var(--font-serif);
  font-style: italic;
}

/* Meta list — label uppercase, value tegas */
.modal-meta {
  list-style: none; padding: 0; margin: 0 0 8px;
  display: grid; gap: 0;
}
.modal-meta li {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 16px; align-items: baseline;
  font-size: .92rem;
  padding: 11px 0;
  border-bottom: 1px dashed rgba(238,221,211,.85);
}
.modal-meta li:last-child { border-bottom: 0; }
.modal-meta span {
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-style: normal;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.modal-meta strong {
  color: var(--ink); font-weight: 600;
  font-size: .96rem;
}

/* Actions — flex footer di bawah panel. TIDAK ikut scroll karena
   dia di luar .modal-body, hanya body yang punya overflow-y. */
.modal-actions {
  flex: 0 0 auto;
  padding: 18px 44px 24px;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex; gap: 10px;
}
.modal-actions .btn {
  flex: 1;
  padding: 15px 24px;
  font-size: .96rem;
  font-weight: 600;
  letter-spacing: .02em;
  background: linear-gradient(180deg, var(--brand-light) 0%, var(--brand) 100%);
  box-shadow:
    0 1px 0 rgba(255,255,255,.18) inset,
    0 10px 24px -8px rgba(201,86,110,.55);
  border-radius: 999px;
}
/* Spesifisitas tinggi untuk menang dari .btn-primary di components.css —
   kalau tidak, dua definisi :hover bertumpuk. */
.modal-actions .btn.btn-primary,
.modal-actions .btn.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand-light) 0%, var(--brand) 100%);
  color: #fff;
  border-color: transparent;
}
.modal-actions .btn.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255,255,255,.18) inset,
    0 14px 28px -10px rgba(201,86,110,.65);
}

body.modal-open { overflow: hidden; }

/* ─── MOBILE ───────────────────────────────────────────── */
@media (max-width: 760px) {
  .modal-backdrop {
    padding: 20px 12px 0;
    align-items: flex-end;
    background: rgba(42,23,20,.62);
    backdrop-filter: blur(6px) saturate(150%);
    -webkit-backdrop-filter: blur(6px) saturate(150%);
  }
  .modal {
    grid-template-columns: 1fr;
    max-width: 100%;
    /* Mobile: fixed height, tapi TIDAK full viewport — sisakan gap
       di atas supaya tidak mentok status bar. Konsisten antar produk. */
    height: min(88vh, 720px);
    max-height: calc(100vh - 20px);
    border-radius: 28px 28px 0 0;
    box-shadow:
      0 -8px 40px -8px rgba(42,23,20,.35),
      0 -2px 8px -2px rgba(42,23,20,.15);
  }

  /* Mobile: media baris pertama (fixed tinggi via aspect-ratio),
     body baris kedua (isi sisa, scroll internal). Modal tinggi tetap,
     body scroll kalau konten panjang. */
  .modal {
    grid-template-rows: auto minmax(0, 1fr);
  }
  .modal-media {
    flex: 0 0 auto;
    height: auto;
    overflow: hidden;
  }
  .modal-media-main {
    aspect-ratio: 16 / 10;
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
  }

  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 26px 22px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-body .card-kategori { margin-bottom: 10px; }
  .modal-nama {
    font-size: 1.55rem;
    line-height: 1.1;
    margin-bottom: 12px;
    padding-bottom: 16px;
  }
  .modal-badge { margin-bottom: 16px; font-size: .64rem; padding: 5px 12px 5px 9px; }
  .modal-deskripsi { font-size: .95rem; margin-bottom: 20px; }

  .modal-harga { margin-bottom: 22px; padding-bottom: 18px; gap: 10px; }
  .modal-harga .harga-diskon,
  .modal-harga .harga-now { font-size: 1.7rem; }
  .modal-harga .harga-strike { font-size: .92rem; }

  .modal-meta li {
    grid-template-columns: 88px 1fr;
    padding: 10px 0;
    font-size: .88rem;
  }
  .modal-meta strong { font-size: .92rem; }

  .modal-close {
    top: 14px; right: 14px;
    width: 38px; height: 38px;
    font-size: 18px;
  }

  /* Action bar mobile: flex footer — sama seperti desktop, tidak scroll. */
  .modal-actions {
    flex: 0 0 auto;
    padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px -14px rgba(44,26,24,.15);
  }
  .modal-actions .btn { padding: 15px 22px; font-size: .95rem; }
}
