/* ==========================================================================
   Avarith UMKM — app.css
   Layout + komponen. Semua nilai dari tokens.css.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--h1); font-weight: 800; }
h2 { font-size: var(--h2); font-weight: 700; }
h3 { font-size: var(--h3); font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: var(--ink); }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: var(--small); }
.hide { display: none !important; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hair);
}
.nav .in {
  max-width: var(--container); margin: 0 auto; padding: 0 20px;
  height: var(--nav-h); display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-head); font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand i {
  width: 30px; height: 30px; border-radius: 9px; font-style: normal;
  background: var(--fill); color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 800;
}
.brand span b { color: var(--muted); font-weight: 700; }
.nav .grow { flex: 1; }
.nav .link { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav .link:hover { color: var(--ink); }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--r-btn); padding: 10px 20px;
  font-weight: 700; font-size: 14.5px; text-decoration: none;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.btn-p { background: var(--fill); color: #fff; box-shadow: 0 4px 14px rgba(19,62,135,.22); }
.btn-p:hover { background: var(--fill-hi); }
.btn-o { background: transparent; color: var(--ink); border: 1.5px solid var(--hair-2); }
.btn-o:hover { background: var(--surface-lo); border-color: var(--accent); }
.btn-g { background: transparent; color: var(--muted); }
.btn-g:hover { color: var(--ink); }
.btn-wa { background: #1FAF57; color: #fff; }
.btn-wa:hover { background: #178A44; }
.btn-danger { background: transparent; color: var(--err); border: 1.5px solid color-mix(in srgb, var(--err) 35%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--err) 8%, transparent); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-lg { padding: 13px 26px; font-size: 15.5px; border-radius: 12px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ---------- search ---------- */
.search {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1.5px solid var(--hair-2); border-radius: var(--r-pill);
  padding: 4px 4px 4px 16px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(19,62,135,.10); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 14.5px; min-width: 0; }
.search input::placeholder { color: var(--muted); }
.search .btn { padding: 8px 16px; border-radius: var(--r-pill); }

/* chip pemahaman pencarian pintar */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips .lbl { font-size: var(--tiny); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.chip {
  font-size: 12.5px; font-weight: 700; color: var(--ink);
  background: var(--surface); border-radius: var(--r-pill); padding: 4px 13px;
}
.chip button { border: 0; background: none; color: var(--ink); font-weight: 800; padding: 0 0 0 6px; }

/* ---------- layout direktori ---------- */
.dir { display: grid; grid-template-columns: var(--aside-w) 1fr; gap: 28px; padding: 28px 0 64px; align-items: start; }

.aside { position: sticky; top: calc(var(--nav-h) + 20px); display: flex; flex-direction: column; gap: 22px; }
.aside .group { display: flex; flex-direction: column; gap: 4px; }
.aside .group > .lbl { font-size: var(--tiny); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.catbtn {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border: 0; background: none; border-radius: var(--r-btn);
  padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--ink);
  transition: background var(--dur);
}
.catbtn:hover { background: var(--surface-lo); }
.catbtn.on { background: var(--surface); font-weight: 700; }
.catbtn .n { margin-left: auto; font-size: var(--tiny); color: var(--muted); font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; padding: 6px 12px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--fill); }
.aside select {
  border: 1.5px solid var(--hair-2); border-radius: var(--r-btn); padding: 8px 10px;
  background: var(--card); font-size: 13.5px; margin: 0 12px;
}

/* ---------- kartu toko ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tcard {
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--r-card);
  overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.tcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.tcard .ph { height: 140px; background: var(--surface); position: relative; overflow: hidden; }
.tcard .ph img { width: 100%; height: 100%; object-fit: cover; }
.tcard .ph .initial {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--font-head); font-size: 40px; font-weight: 800; color: var(--muted);
}
.badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.94);
}
.badge.open { color: #1E8E43; }
.badge.closed { color: var(--err); }
.tcard .bd { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.tcard h3 { font-size: 15.5px; }
.tcard .meta { display: flex; flex-wrap: wrap; gap: 3px 12px; font-size: 12.5px; color: var(--muted); }
.tcard .meta b { color: var(--ink); font-weight: 700; }
.tcard .addr { font-size: 12px; color: var(--muted); margin-top: auto; padding-top: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* empty state */
.empty {
  grid-column: 1 / -1; text-align: center; padding: 72px 24px;
  background: var(--card); border: 1.5px dashed var(--hair-2); border-radius: var(--r-card);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty .big { font-size: 40px; }
.empty p { color: var(--muted); max-width: 46ch; }

/* ---------- halaman form (daftar / kelola) ---------- */
.page-narrow { max-width: 720px; margin: 0 auto; padding: 40px 20px 80px; display: flex; flex-direction: column; gap: 24px; }
.card-block { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r-card); padding: 28px; box-shadow: var(--shadow); }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field > label { font-size: var(--tiny); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field .ai-link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 700; font-size: 12.5px; text-transform: none; letter-spacing: 0; }
.field .ai-link:hover { text-decoration: underline; }
.field .ai-link[disabled] { color: var(--muted); text-decoration: none; cursor: wait; }
.in {
  width: 100%; background: var(--card); border: 1.5px solid var(--hair-2); border-radius: var(--r-btn);
  padding: 10px 13px; font-size: 14.5px; outline: 0;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.in:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(19,62,135,.10); }
textarea.in { min-height: 110px; resize: vertical; line-height: 1.55; }
.hint { font-size: var(--tiny); color: var(--muted); }
.hint.err { color: var(--err); font-weight: 600; }
.hint.ok { color: #1E8E43; font-weight: 600; }

/* upload foto */
.uploader { border: 2px dashed var(--hair-2); border-radius: var(--r-card); padding: 20px; text-align: center;
  color: var(--muted); font-size: 13.5px; cursor: pointer; transition: background var(--dur); background: var(--page); }
.uploader:hover { background: var(--surface-lo); }
.previews { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.previews .pv { position: relative; width: 92px; height: 92px; border-radius: 12px; overflow: hidden; border: 1px solid var(--hair); }
.previews .pv img { width: 100%; height: 100%; object-fit: cover; }
.previews .pv button {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 99px; border: 0;
  background: rgba(255,255,255,.95); color: var(--err); font-weight: 800; font-size: 12px; line-height: 1;
}

/* panel sukses */
.success-panel { border: 1.5px solid var(--ok); background: color-mix(in srgb, var(--ok) 6%, var(--card)); }
.copybox {
  display: flex; gap: 8px; align-items: center; background: var(--page);
  border: 1px solid var(--hair-2); border-radius: var(--r-btn); padding: 9px 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all;
}
.copybox button { flex: 0 0 auto; }

/* ---------- halaman toko ---------- */
.store-head { display: flex; flex-direction: column; gap: 14px; padding: 36px 0 8px; }
.store-head .cat { font-size: 13px; font-weight: 700; color: var(--muted); }
.store-head .meta { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; color: var(--muted); }
.store-head .meta b { color: var(--ink); }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 18px 0; }
.gallery img { width: 100%; height: 220px; object-fit: cover; border-radius: var(--r-card); border: 1px solid var(--hair); }
.gallery .initial { height: 220px; border-radius: var(--r-card); background: var(--surface); display: grid; place-items: center;
  font-family: var(--font-head); font-size: 56px; font-weight: 800; color: var(--muted); }
.store-body { display: grid; grid-template-columns: 1fr 300px; gap: 28px; padding-bottom: 72px; align-items: start; }
.store-desc { font-size: var(--lead); line-height: 1.7; max-width: 65ch; white-space: pre-line; }
.sidecard { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r-card); padding: 22px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; position: sticky; top: calc(var(--nav-h) + 20px); }
.sidecard .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.sidecard .row .k { color: var(--muted); }
.sidecard .row .v { font-weight: 600; text-align: right; }
.sidecard hr { border: 0; border-top: 1px solid var(--hair); margin: 4px 0; width: 100%; }
.status-open { color: #1E8E43; font-weight: 800; }
.status-closed { color: var(--err); font-weight: 800; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 700;
  padding: 11px 22px; border-radius: var(--r-pill); box-shadow: var(--shadow-card); z-index: 99;
}

/* footer */
.footer { border-top: 1px solid var(--hair); padding: 24px 0 32px; }
.footer .in { max-width: var(--container); margin: 0 auto; padding: 0 20px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: var(--small); color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .dir { grid-template-columns: 1fr; }
  .aside { position: static; flex-direction: column; }
  .aside .group.cats { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 6px; }
  .aside .group.cats > .lbl { display: none; }
  .catbtn { white-space: nowrap; border: 1px solid var(--hair-2); border-radius: var(--r-pill); padding: 7px 14px; }
  .catbtn .n { display: none; }
  .store-body { grid-template-columns: 1fr; }
  .sidecard { position: static; }
  .fgrid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav .in { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 8px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .nav .link { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
