/* Karsa extend — gaya pendamping untuk fungsi dinamis Usaha MbahMan.
   Token meniru styles.css asli (var --background, --foreground, --accent, --border, --stage).
   app.js dan PHP logic tidak diubah; selector menempel pada ID/class yang sudah ada. */

/* Latar panggung disamakan krem seperti konten (bukan hitam). */
:root { --stage: oklch(0.965 0.011 86); }
/* Bayangan bingkai situs hanya cocok di panggung gelap — matikan agar menyatu. */
.site-shell { box-shadow: none; }

/* ---------- Reveal / press / skeleton (dari main.css, retoken) ---------- */
html { scroll-behavior: smooth; }
html.js .reveal { opacity: 0; }
.press { transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease; }
.press:active { transform: scale(.98); }
.skeleton {
  background: linear-gradient(90deg, var(--muted) 25%, var(--secondary) 37%, var(--muted) 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease infinite;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
details > summary::-webkit-details-marker { display: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.prose-desc { white-space: pre-line; overflow-wrap: anywhere; }
.hide-scroll { scrollbar-width: none; }
.hide-scroll::-webkit-scrollbar { display: none; }

/* ---------- Toast: diposisikan seperti cart-toast Karsa ---------- */
#toast-root {
  position: fixed; z-index: 50; right: 18px; bottom: 18px;
  left: auto !important; transform: none !important;
  width: min(calc(100% - 2rem), 22rem);
  display: grid; gap: 8px; pointer-events: none;
}
.toast-item {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  background: var(--foreground); color: var(--background);
  box-shadow: 0 10px 30px oklch(0 0 0 / 30%);
  padding: 11px 12px 11px 18px; font-size: 10px; text-transform: uppercase;
}
.toast-item.success, .toast-item.error { background: var(--foreground); }

/* ---------- Baris pencarian (di bawah header, dalam shell) ---------- */
.search-row { border-bottom: 1px solid var(--border); background: var(--background); }
.search-row[hidden] { display: none; }
.search-row form { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px clamp(18px, 4vw, 44px); }
.search-row input[type="search"] {
  flex: 1; min-width: 0; background: transparent; border: 0;
  border-bottom: 1px solid var(--border); padding: 11px 0; font-size: 11px; outline: none;
}
.search-row input[type="search"]::placeholder { color: var(--muted-foreground); }
#cat-menu { position: relative; }
#cat-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 10px; text-transform: uppercase; padding: 10px 0; user-select: none; }
#cat-menu > div {
  position: absolute; left: 0; top: calc(100% + 10px); z-index: 30; width: 240px;
  background: var(--background); border: 1px solid var(--border); padding: 8px; display: grid;
}
#cat-menu > div a { display: flex; align-items: center; gap: 8px; padding: 12px; font-size: 11px; text-transform: uppercase; }
#cat-menu > div a:hover { background: var(--muted); }
#search-results {
  position: absolute; left: clamp(18px, 4vw, 44px); right: clamp(18px, 4vw, 44px); top: 100%; z-index: 30;
  background: var(--background); border: 1px solid var(--border);
  max-height: 70vh; overflow-y: auto; padding: 8px;
  box-shadow: 0 10px 30px oklch(0 0 0 / 18%);
}
#search-results a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; font-size: 11px; }
#search-results a:hover { background: var(--muted); }
#search-results p { font-size: 11px; }
#search-results .text-center { text-align: center; }

.nav-group a[aria-current="page"], .mobile-menu a[aria-current="page"] {
  text-decoration: underline; text-underline-offset: 4px;
  color: var(--foreground); font-weight: 600;
}
/* Brand "Lapak MbahMan." lebih panjang dari "Karsa." — jangan pecah baris, kecilkan di layar sempit. */
.brand { white-space: nowrap; }
@media (max-width: 639px) {
  .brand { font-size: 24px; }
  .site-header { padding-inline: 14px; }
}

/* ---------- Navigasi bawah mobile: fixed, selalu terlihat ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--background); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav ul { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 0; list-style: none; }
.bottom-nav a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 58px; font-weight: 600;
  color: var(--ink-soft); font-size: 9px; text-transform: uppercase;
}
.bottom-nav a[aria-current="page"] { color: var(--foreground); }
.bottom-nav a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
  background: var(--accent); border-radius: 0 0 3px 3px;
}
.bottom-nav a[aria-current="page"] i { color: var(--accent); }
@media (min-width: 768px) { .bottom-nav { display: none; } }
/* Ruang agar bottom-nav fixed tidak menutupi konten di HP. */
@media (max-width: 767px) {
  /* Jarak lega: tinggi bar (58px) + napas 18px + area poni HP. */
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  /* Toast ikut naik agar tidak ketutup bar. */
  #toast-root { bottom: calc(76px + env(safe-area-inset-bottom)); }
  /* Footer hanya untuk desktop — di HP disembunyikan total. */
  footer { display: none; }
  /* Tombol cari di paling kanan dengan jarak lega dari judul. */
  .site-header { display: flex; align-items: center; gap: 16px; }
  .site-header .brand { flex: 1; text-align: left; }
  /* Tombol install muat di layar sangat sempit: tinggal ikon. */
  @media (max-width: 380px) { #install-btn span { display: none; } }
  /* Header menempel + sembunyi saat scroll ke bawah (muncul lagi saat scroll ke atas). */
  .site-shell { overflow: visible; }
  .site-header {
    position: sticky; top: 0; z-index: 40;
    background: var(--background);
    transition: transform .25s ease;
  }
  .site-header.header-hidden { transform: translateY(-102%); }
}

/* ---------- Dropdown kustom (pengganti picker modal bawaan HP) ---------- */
.k-filterbar .cdrop { flex: 1 1 160px; min-width: 0; }
.k-field .cdrop { width: 100%; }
.cdrop { position: relative; }
.cdrop > button {
  width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--border);
  padding: 11px 0; font-size: 11px; color: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
}
.cdrop > button .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdrop-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--background); border: 1px solid var(--border); padding: 6px;
  max-height: 260px; overflow-y: auto;
  box-shadow: 0 10px 30px oklch(0 0 0 / 18%);
}
.cdrop-panel button {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 12px;
  font-size: 11px; text-transform: uppercase; background: none; border: 0;
  cursor: pointer; color: inherit; text-align: left;
}
.cdrop-panel button:hover { background: var(--muted); }
.cdrop-panel button[aria-selected="true"] { font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Kotak unggah foto: terlihat seperti tombol ---------- */
.df-uploadbox {
  display: flex; align-items: center; gap: 14px; width: 100%;
  border: 1.5px dashed var(--foreground); padding: 18px; cursor: pointer;
  background: transparent; text-align: left;
}
.df-uploadbox:hover, .df-uploadbox:focus-within { background: var(--muted); }
.df-uploadbox > i { font-size: 30px; color: var(--accent); flex-shrink: 0; }
.df-uploadbox strong { display: block; font-size: 11px; text-transform: uppercase; }
.df-uploadbox small { display: block; font-size: 10px; color: var(--muted-foreground); margin-top: 4px; }
.df-uploadbox input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ---------- Modal sukses pendaftaran ---------- */
.dmodal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: oklch(0 0 0 / 55%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.dmodal-overlay[hidden] { display: none; }
.dmodal {
  background: var(--background); border: 1px solid var(--border);
  max-width: 420px; width: 100%; padding: 36px 28px; text-align: center;
}
.dmodal h2 { font-size: 26px; font-weight: 500; margin-top: 14px; }
.dmodal p { font-size: 11px; line-height: 1.6; margin-top: 10px; }
.dmodal .k-btn-oval { margin-top: 20px; }

/* ---------- Pita hero halaman dalam (pengganti hero_banner gradien) ---------- */
.k-band { border-bottom: 1px solid var(--border); padding: 42px clamp(22px, 5vw, 50px) 34px; }
.k-band h1 { font-size: clamp(34px, 5vw, 56px); font-weight: 400; line-height: .95; margin-top: 14px; }
.k-band > p { max-width: 570px; font-size: 11px; line-height: 1.6; margin-top: 12px; }
.k-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 10px; text-transform: uppercase; }
.k-crumb a { border-bottom: 1px solid var(--foreground); padding-bottom: 2px; }
.k-crumb [aria-current="page"] { color: var(--ink-soft); }

/* ---------- Badge, empty state, paginasi ---------- */
.k-badge {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; font-size: 9px; text-transform: uppercase;
}
.k-empty { border: 1px solid var(--border); padding: 40px 24px; text-align: center; }
.k-empty p { margin-top: 12px; font-size: 11px; line-height: 1.6; }
.k-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 32px; padding-bottom: 8px; }
.k-pager a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding-inline: 12px;
  border: 1px solid var(--foreground); border-radius: 50%;
  font-size: 10px; text-transform: uppercase;
}
.k-pager a[aria-current="page"] { background: var(--foreground); color: var(--background); }

/* ---------- Form & tabel (daftar filter + admin) ---------- */
.k-input, .k-select, .k-textarea {
  width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--border);
  padding: 11px 0; font-size: 11px; outline: none; color: inherit;
}
.k-input::placeholder, .k-textarea::placeholder { color: var(--muted-foreground); }
.k-select { cursor: pointer; }
.k-label { display: block; font-size: 9px; text-transform: uppercase; margin-bottom: 2px; }
.k-field { display: grid; gap: 4px; margin-bottom: 18px; }
.k-btn-oval {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 112px; min-height: 45px; padding-inline: 18px;
  border: 1px solid var(--foreground); border-radius: 50%;
  font-size: 8px; text-transform: uppercase; background: transparent; cursor: pointer;
  transition: background-color .2s, color .2s;
}
.k-btn-oval:hover { background: var(--foreground); color: var(--background); }
.k-btn-oval:disabled { opacity: .5; cursor: wait; }
.k-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.k-table th { font-size: 9px; text-transform: uppercase; text-align: left; padding: 12px; border-bottom: 1px solid var(--border); }
.k-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.k-table tr:last-child td { border-bottom: 0; }
.k-card { border: 1px solid var(--border); padding: 24px; }
.k-card h2, .k-card h3 { font-weight: 500; }
.k-alert { border: 1px solid var(--border); padding: 12px 16px; font-size: 11px; line-height: 1.5; margin-bottom: 16px; }
.k-grid-form { display: grid; gap: 0; }
.k-thumb { width: 44px; height: 44px; object-fit: cover; }
.admin-wrap { padding: 32px clamp(22px, 5vw, 50px) 48px; }
.admin-wrap > h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 400; line-height: 1; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.admin-nav a { padding: 14px 18px; font-size: 10px; text-transform: uppercase; border-right: 1px solid var(--border); }
.admin-nav a[aria-current="page"] { background: var(--foreground); color: var(--background); }

/* ---------- Kartu daftar (usaha/produk/kegiatan): sel Karsa ---------- */
.k-cell { position: relative; padding: 24px 18px 28px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.k-cell h3 { margin-top: 12px; font-size: 11px; font-weight: 500; text-transform: uppercase; }
.k-cell p { margin-top: 5px; font-size: 9px; }
.k-img-frame { position: relative; width: 100%; aspect-ratio: 1 / 1.05; overflow: hidden; background: var(--muted); }
.k-img-frame img { width: 100%; height: 100%; object-fit: cover; }
.k-tag {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--background); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; font-size: 8px; text-transform: uppercase;
}
.k-date-block {
  width: 64px; height: 64px; flex-shrink: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1; border: 1px solid var(--border);
}
.k-date-block strong { font-size: 20px; font-weight: 500; }
.k-date-block span { font-size: 9px; text-transform: uppercase; margin-top: 4px; }

/* ---------- Detail: dua kolom ala delivery-grid ---------- */
.k-detail-grid { display: grid; border-bottom: 1px solid var(--border); }
@media (min-width: 768px) { .k-detail-grid { grid-template-columns: 1fr 1fr; } }
.k-detail-copy { display: flex; min-height: 420px; flex-direction: column; align-items: flex-start; padding: clamp(32px, 5vw, 55px); gap: 14px; }
.k-detail-copy h1 { font-size: clamp(34px, 5vw, 56px); font-weight: 400; line-height: .95; }
.k-detail-copy p, .k-detail-copy li { font-size: 11px; line-height: 1.6; }
.k-detail-copy .prose-desc { max-width: 420px; }

/* ---------- Baris kegiatan ---------- */
.k-giat-list { display: grid; border-bottom: 1px solid var(--border); }
.k-giat-row { display: flex; gap: 18px; padding: 24px clamp(22px, 5vw, 50px); border-bottom: 1px solid var(--border); align-items: flex-start; }
.k-giat-row:last-child { border-bottom: 0; }
.k-giat-row h3 { font-size: 13px; font-weight: 500; text-transform: uppercase; }
.k-giat-row p { margin-top: 5px; font-size: 10px; color: var(--ink-soft); }
.k-price { font-family: var(--font-serif); font-size: 34px; line-height: 1; margin-top: 10px; }
/* Harga di halaman detail: menangkan spesifisitas atas .k-detail-copy p (11px). */
.k-detail-copy .k-price { font-size: clamp(30px, 6vw, 46px); margin-top: 4px; }

/* ---------- Admin (Gaya Karsa minimal) ---------- */
.admin-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); min-height: 56px; }
.admin-row:last-child { border-bottom: 0; }
.admin-row .grow { flex: 1; min-width: 0; }
.admin-row .t { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-row .s { font-size: 10px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.admin-check { display: flex; align-items: center; gap: 12px; min-height: 44px; border: 1px solid var(--border); padding: 10px 12px; font-size: 11px; background: var(--background); }
.admin-check input, .k-checkline input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.k-checkline { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 11px; }
.admin-stat { display: block; border: 1px solid var(--border); padding: 20px 12px; text-align: center; }
.admin-stat strong { display: block; font-family: var(--font-serif); font-size: 38px; font-weight: 500; line-height: 1; }
.admin-stat span { font-size: 9px; text-transform: uppercase; }
.admin-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
@media (min-width: 768px) { .admin-toolbar { flex-direction: row; } .admin-toolbar .grow { flex: 1; } }
.admin-2col { display: grid; gap: 0; }
@media (min-width: 640px) { .admin-2col { grid-template-columns: 1fr 1fr; gap: 16px; } }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--border); }
.admin-stats .admin-stat { border: 0; border-right: 1px solid var(--border); }
.admin-stats .admin-stat:last-child { border-right: 0; }
.a-thumb { width: 48px; height: 48px; object-fit: cover; flex-shrink: 0; background: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 20px; overflow: hidden; }
.a-thumb img { width: 100%; height: 100%; object-fit: cover; }
.a-icobtn { display: inline-grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--foreground); border-radius: 50%; background: transparent; color: inherit; cursor: pointer; transition: background-color .2s, color .2s; }
.a-icobtn:hover { background: var(--foreground); color: var(--background); }
.a-icobtn.danger { border-color: var(--accent); color: var(--accent); }
.a-icobtn.danger:hover { background: var(--accent); color: var(--background); }
.a-actions { display: flex; gap: 8px; flex-shrink: 0; }
.a-actions form { display: inline; }
.admin-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.admin-login .k-card { width: 100%; max-width: 380px; }
.admin-login .brand { font-size: 32px; }

/* ---------- Util ---------- */
.k-section-pad { padding: 36px clamp(22px, 5vw, 50px); }
.k-list-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .k-list-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .k-list-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.k-filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 20px clamp(22px, 5vw, 50px); border-bottom: 1px solid var(--border); }
.k-filterbar .k-input, .k-filterbar .k-select { width: auto; flex: 1 1 160px; }
.k-meta { font-size: 9px; text-transform: uppercase; }
.k-muted { color: var(--muted-foreground); }

@media (max-width: 767px) {
  .k-cell { padding: 20px 12px 24px; }
  .k-detail-copy { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html.js .reveal { opacity: 1 !important; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
