/* =====================================================
   PT. Sabaraya Sagara Mandiri - Halaman Products
   Memakai variabel & komponen global dari style.css.
   Semua class di file ini berawalan "cat-" agar tidak
   bentrok dengan .product-grid / .product-card milik
   section "Produk Unggulan" di index.html.
   ===================================================== */

/* ---------- 1. Header halaman (ringkas) ---------- */
.cat-hero {
  padding: 48px 0 40px;
  text-align: center;
  background: var(--light);
  border-bottom: 1px solid #E6EAF3;
}
.cat-hero h1 {
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--dark);
}
.cat-hero h1 span { color: var(--primary); }
.cat-hero h1::after {   /* aksen merah kecil */
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  margin: 14px auto 0;
  border-radius: 4px;
}
.cat-hero p {
  max-width: 36rem;
  margin: 16px auto 0;
  font-size: 1rem;
  color: var(--muted);
}

/* Teks khusus pembaca layar */
.cat-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 2. Layout: produk (kiri) + sidebar (kanan) ---------- */
.cat-section { padding: 48px 0 96px; background: var(--white); }

.cat-layout {
  display: grid;
  /* sidebar ±22-28% lebar container */
  grid-template-columns: minmax(0, 1fr) clamp(240px, 26%, 312px);
  gap: 40px;
  align-items: start;
}
.cat-main { min-width: 0; }

/* ---------- 3. Filter kategori utama + pencarian + status ---------- */
.cat-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
  scroll-margin-top: calc(var(--nav-h) + 16px);
}

.cat-search { position: relative; max-width: 380px; }
.cat-search .bi-search {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  color: var(--muted);
  pointer-events: none;
}
.cat-search input {
  width: 100%;
  padding: .62rem 1.1rem .62rem 2.5rem;
  border: 1.5px solid #D5DBEA;
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: .88rem;
  color: var(--dark);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.cat-search input::placeholder { color: #9AA3B8; }
.cat-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 21, 245, .08);
}
.cat-search input::-webkit-search-cancel-button { cursor: pointer; }

.cat-chips { display: flex; flex-wrap: wrap; gap: 10px; }

.cat-chip {
  padding: .55rem 1.1rem;
  border: 1.5px solid #D5DBEA;
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--dark);
  cursor: pointer;
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}
.cat-chip:hover { border-color: var(--primary); color: var(--primary); }
.cat-chip[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.cat-status { font-size: .88rem; color: var(--muted); }
.cat-status strong { color: var(--dark); font-weight: 600; }

/* ---------- 4. Grid produk (otomatis menyesuaikan jumlah) ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: #fff;
  border: 1px solid #E3E8F2;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(20, 30, 80, .04);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
  animation: catIn .35s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.cat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(21, 21, 245, .35);
  box-shadow: 0 10px 24px rgba(21, 21, 245, .08);
}
@keyframes catIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Area foto: SELALU persegi (1:1). Foto diletakkan utuh (contain), tidak dipotong.
   Latar putih agar foto berlatar putih menyatu dengan kartu (tanpa bingkai ganda).
   Latar abu-abu hanya dipakai saat placeholder (belum ada foto / gagal dimuat). */
.cat-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
}
.cat-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 24px;
}
.cat-image.is-missing { background: #f7f7f7; }

/* Placeholder bila foto belum ada / gagal dimuat */
.cat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: #8A93A8;
  border: 1px dashed #CBD2E3;
  border-radius: 12px;
  margin: 12px;
}
.cat-placeholder svg { width: 40px; height: 40px; }
.cat-placeholder span { font-size: .8rem; line-height: 1.4; }
.cat-image.is-missing { padding: 0; }
.cat-image.is-missing .cat-placeholder { margin: 12px; }

.cat-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 4px;
  padding: 16px 6px 6px;
}
.cat-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--primary);
}
.cat-name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
  color: var(--dark);
}

/* Kartu bisa diklik: seluruh isi kartu dibungkus tautan */
.cat-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.cat-card-link:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }

.cat-pack {
  font-size: .82rem;
  line-height: 1.4;
  color: var(--muted);
}

.cat-foot {
  display: flex;
  justify-content: center;
  margin-top: auto;
  padding-top: 14px;
}
.cat-detail {
  display: inline-flex;
  align-items: center;
  padding: .5rem 1.1rem;
  border: 1.5px solid #D5DBEA;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dark);
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}
.cat-card:hover .cat-detail {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.cat-variant {
  font-size: .78rem;
  line-height: 1.4;
  color: var(--muted);
}

/* Tombol "muat lebih banyak" untuk daftar produk yang panjang */
.cat-more {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}
.cat-more-btn {
  padding: .65rem 1.4rem;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--primary);
  cursor: pointer;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
.cat-more-btn:hover { background: var(--primary); color: #fff; }

/* ---------- 5. Empty state ---------- */
.cat-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--light);
  border: 1px dashed #C9D2EC;
  border-radius: 16px;
}
.cat-empty svg { width: 44px; height: 44px; color: var(--primary); opacity: .75; }
.cat-empty p { font-size: 1rem; font-weight: 500; color: var(--dark); }
.cat-empty-btn {
  margin-top: 4px;
  padding: .55rem 1.1rem;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
  cursor: pointer;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
.cat-empty-btn:hover { background: var(--primary); color: #fff; }

.cat-noscript { grid-column: 1 / -1; padding: 24px; text-align: center; color: var(--muted); }

/* ---------- 6. Sidebar KATALOG (biru) ---------- */
.cat-side {
  top: calc(var(--nav-h) + 24px);
  padding: 4px 20px 14px;
  color: #fff;
  background: var(--primary);
  border-radius: 20px;
  box-shadow: 0 14px 36px rgba(21, 21, 245, .18);
}

.cat-side-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 18px 0 14px;
  border: 0;
  background: none;
  font: inherit;
  color: #fff;
  text-align: left;
  cursor: default;          /* di desktop hanya judul; jadi tombol di mobile */
}
.cat-side-title {
  position: relative;
  padding-bottom: 10px;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .16em;
}
.cat-side-title::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 28px;
  height: 3px;
  border-radius: 3px;
  background: var(--red);
}
.cat-side-chevron { display: none; }

/* Panah kecil (dibuat dengan CSS, tanpa icon font) */
.cat-chevron {
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);        /* tertutup: menunjuk ke kanan */
  transition: transform .25s var(--ease);
}
.cat-group.is-open .cat-chevron { transform: rotate(45deg); }   /* terbuka: menunjuk ke bawah */

.cat-group { border-top: 1px solid rgba(255, 255, 255, .18); }

.cat-group-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 4px;
  border: 0;
  background: none;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
  color: #fff;
  cursor: pointer;
}
.cat-group-label { display: inline-flex; align-items: center; }
.cat-group-label::before {      /* penanda kategori yang sedang aktif */
  content: "";
  width: 0;
  height: 8px;
  margin-right: 0;
  border-radius: 50%;
  background: #fff;
  transition: width .25s var(--ease), margin-right .25s var(--ease);
}
.cat-group.is-current .cat-group-label::before { width: 8px; margin-right: 10px; }

/* Accordion buka/tutup halus */
.cat-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s var(--ease);
}
.cat-group.is-open .cat-panel { grid-template-rows: 1fr; }
.cat-panel-inner { min-height: 0; overflow: hidden; }
.cat-sublist { padding-bottom: 10px; }

.cat-sub {
  display: block;
  width: 100%;
  margin-bottom: 2px;
  padding: 9px 12px 9px 18px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: .9rem;
  line-height: 1.4;
  text-align: left;
  color: rgba(255, 255, 255, .9);
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.cat-sub:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.cat-sub[aria-current="true"] {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
}

/* Penanda "subkategori ini punya brand" (chevron kecil) */
.cat-sub .cat-sub-mark {
  display: none;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);          /* tertutup: menunjuk ke kanan */
  transition: transform .25s var(--ease);
}
.cat-sub-item > .cat-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cat-sub-item > .cat-sub .cat-sub-mark { display: inline-block; }
.cat-sub-item.is-open .cat-sub-mark { transform: rotate(45deg); }   /* terbuka: ke bawah */

/* Daftar brand (subitem subkategori; terbuka hanya saat subkategori aktif) */
.cat-brandlist {
  display: none;
  margin: 2px 0 8px;
  padding-left: 8px;
  list-style: none;
  border-left: 1px solid rgba(255, 255, 255, .25);
}
.cat-sub-item.is-open .cat-brandlist { display: block; }
.cat-brand {
  display: block;
  width: 100%;
  margin: 2px 0;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: .84rem;
  line-height: 1.35;
  text-align: left;
  color: rgba(255, 255, 255, .82);
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.cat-brand::before { content: "–"; margin-right: 8px; opacity: .6; }
.cat-brand:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.cat-brand[aria-current="true"] {
  background: rgba(255, 255, 255, .92);
  color: var(--primary);
  font-weight: 600;
}
.cat-brand[aria-current="true"]::before { content: "–"; }

/* Fokus keyboard terlihat di atas latar biru */
.cat-side :focus-visible { outline-color: #fff; outline-offset: 2px; }

/* ---------- 7. Responsif ---------- */

/* Laptop kecil / tablet landscape: sidebar tetap di kanan, grid 2 kolom */
@media (max-width: 1099px) {
  .cat-layout { gap: 28px; }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablet portrait & mobile: sidebar pindah ke atas sebagai accordion */
@media (max-width: 899px) {
  .cat-hero { padding: 40px 0 32px; }
  .cat-section { padding: 32px 0 72px; }

  .cat-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }

  .cat-side {
    position: static;
    order: -1;
    padding: 0 18px 4px;
    border-radius: 16px;
  }
  .cat-side-toggle { padding: 16px 0; cursor: pointer; }
  .cat-side-title { padding-bottom: 0; }
  .cat-side-title::after { display: none; }
  .cat-side-chevron { display: inline-block; transform: rotate(45deg); }
  .cat-side:not(.is-collapsed) .cat-side-chevron { transform: rotate(-135deg); }
  .cat-side.is-collapsed .cat-side-body { display: none; }
  .cat-side:not(.is-collapsed) .cat-side-body { padding-bottom: 8px; }
}

/* Mobile: 1 kolom */
@media (max-width: 599px) {
  .cat-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .cat-image img { padding: 20px; }
  .cat-chips { gap: 8px; }
  .cat-chip { padding: .5rem .95rem; font-size: .74rem; }
  .cat-hero p { font-size: .95rem; }
}

/* =====================================================
   8. POP-UP DETAIL PRODUK
   ===================================================== */
body.modal-open { overflow: hidden; }

.product-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.product-modal[hidden] { display: none; }

.product-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 45, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: pmFade .2s var(--ease) both;
}

.product-modal-dialog {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  width: min(880px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(8, 16, 55, .35);
  animation: pmIn .26s var(--ease) both;
}

@keyframes pmFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pmIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.product-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid #E3E8F2;
  border-radius: 50%;
  background: #fff;
  color: var(--dark);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.product-modal-close:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.product-modal-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 24px;
  background: #fff;
  border-radius: 20px 0 0 20px;
}
.product-modal-media.is-missing { background: var(--light); }
.product-modal-media img {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}
.product-modal-media .cat-placeholder { margin: 0; }

.product-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 40px 36px 32px;
}

.product-modal-cat {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--primary);
}

.product-modal-title {
  font-size: clamp(1.3rem, 2.4vw, 1.6rem);
  line-height: 1.25;
  color: var(--dark);
}

.product-modal-desc {
  font-size: .95rem;
  line-height: 1.65;
  color: var(--muted);
}

.product-modal-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin: 8px 0 4px;
  padding-top: 18px;
  border-top: 1px solid #E9EDF6;
}
.product-modal-meta dt {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.product-modal-meta dd {
  margin-top: 4px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--dark);
}
.product-modal-meta .product-modal-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}
.product-modal-meta .product-modal-wide { grid-column: 1 / -1; }

.product-modal-cta {
  align-self: flex-start;
  margin-top: 8px;
}

@media (max-width: 720px) {
  .product-modal { padding: 14px; }
  .product-modal-dialog {
    grid-template-columns: minmax(0, 1fr);
    max-height: calc(100vh - 28px);
    border-radius: 16px;
  }
  .product-modal-media {
    min-height: 0;
    aspect-ratio: 16 / 10;
    padding: 20px;
    border-radius: 16px 16px 0 0;
  }
  .product-modal-media img { max-height: none; }
  .product-modal-body { padding: 26px 22px 24px; }
  .product-modal-meta { grid-template-columns: minmax(0, 1fr); }
  .product-modal-cta { align-self: stretch; text-align: center; }
}
