/* ============ Warunk88 POS ============ */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --ink: #16160f;
  --ink-2: #5a5a4f;
  --ink-3: #8a8a7d;
  --line: #e6e6df;
  --olive: #5f6f35;
  --olive-strong: #4d5b2a;
  --olive-soft: #eef0e4;
  --black: #121210;
  --danger: #b3382e;
  --danger-soft: #fbe9e7;
  --warn: #9a6b00;
  --warn-soft: #fdf3dd;
  --ok: #2e6b3a;
  --ok-soft: #e5f2e7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,20,10,.05), 0 6px 20px rgba(20,20,10,.06);
  --shadow-lg: 0 10px 40px rgba(20,20,10,.18);
  --sidebar-w: 216px;
  --panel-w: 384px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ---------- kerangka ---------- */
#app { height: 100dvh; display: flex; overflow: hidden; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto; background: var(--black); color: #f3f3ec;
  display: flex; flex-direction: column; padding: 14px 10px;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 10px;
}
.sidebar .brand img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.sidebar .brand .t1 { font-weight: 700; letter-spacing: .4px; }
.sidebar .brand .t2 { font-size: .68rem; color: #b9b9a9; letter-spacing: .6px; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px;
  background: none; border: 0; color: #cfcfc2; border-radius: 10px; padding: 0 12px;
  font-size: .94rem; text-align: left;
}
.nav button svg { width: 20px; height: 20px; flex: 0 0 auto; }
.nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav button.active { background: var(--olive); color: #fff; font-weight: 600; }
.sidebar .foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 10px; margin-top: 8px; }
.sidebar .user { display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px; }
.sidebar .user .avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--olive);
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.sidebar .user .name { font-size: .88rem; font-weight: 600; line-height: 1.15; }
.sidebar .user .role { font-size: .72rem; color: #b9b9a9; text-transform: capitalize; }

/* ---------- konten ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px 10px;
}
.topbar h1 { font-size: 1.3rem; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.clock { color: var(--ink-3); font-size: .86rem; white-space: nowrap; }
.content { flex: 1; overflow: auto; padding: 4px 20px 24px; }

/* ---------- tombol ---------- */
.btn {
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600;
  transition: filter .12s, background .12s;
}
.btn:hover { background: #f1f1ea; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn.primary:hover { background: var(--olive-strong); }
.btn.dark { background: var(--black); border-color: var(--black); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #ecece4; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: .88rem; }
.btn.big { min-height: 54px; font-size: 1.05rem; border-radius: var(--radius); }
.btn.block { width: 100%; }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 12px; background: var(--surface); width: 100%;
}
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { outline: 2px solid var(--olive); outline-offset: 0; border-color: var(--olive); }
.hint { font-size: .78rem; color: var(--ink-3); }

/* ---------- kartu & util ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-body { padding: 16px; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: .74rem; font-weight: 700; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: #ededе6; color: var(--ink-2); background: #ededE6; }
.badge.olive { background: var(--olive-soft); color: var(--olive-strong); }
.money { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #1a1a16 0%, #121210 55%, #23240f 100%);
}
.login-card {
  width: 100%; max-width: 410px; background: var(--surface); border-radius: 22px;
  box-shadow: var(--shadow-lg); padding: 34px 30px; text-align: center;
}
.login-card img.logo { width: 110px; height: 110px; object-fit: cover; border-radius: 20px; margin-bottom: 10px; }
.login-card h1 { margin: 4px 0 2px; font-size: 1.45rem; }
.login-card .sub { color: var(--ink-3); font-size: .85rem; letter-spacing: 1.4px; text-transform: uppercase; margin-bottom: 22px; }
.login-card form { text-align: left; }
.login-demo { margin-top: 18px; font-size: .78rem; color: var(--ink-3); line-height: 1.6; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }

/* ---------- layout kasir ---------- */
.pos-layout { display: flex; height: 100%; min-height: 0; gap: 0; }
.pos-center { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 16px 16px 20px; }
.pos-tools { display: flex; gap: 10px; padding: 10px 0; flex-wrap: wrap; align-items: center; }
.pos-search { flex: 1; min-width: 180px; position: relative; }
.pos-search input { padding-left: 40px; }
.pos-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); }
.cat-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: thin; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); white-space: nowrap; font-weight: 600; font-size: .88rem; color: var(--ink-2);
}
.chip.active { background: var(--black); color: #fff; border-color: var(--black); }

.prod-grid {
  flex: 1; overflow-y: auto; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: max-content; align-content: start; padding-bottom: 8px;
}
.prod-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-align: left; padding: 0; display: flex; flex-direction: column;
  transition: transform .08s, box-shadow .12s; position: relative;
}
.prod-card:hover { box-shadow: var(--shadow); }
.prod-card:active { transform: scale(.97); }
.prod-card .ph { height: 104px; flex: 0 0 auto; width: 100%; object-fit: cover; display: block; background: #eceadf; }
.prod-card .ph-fallback {
  height: 104px; flex: 0 0 auto; display: grid; place-items: center; font-weight: 800; font-size: 1.5rem; color: #fff;
}
.prod-card .info { padding: 10px 12px 12px; }
.prod-card .nm { font-weight: 600; font-size: .9rem; line-height: 1.25; min-height: 2.3em; }
.prod-card .pr { color: var(--olive-strong); font-weight: 700; margin-top: 4px; }
.prod-card.soldout { opacity: .55; }
.prod-card .soldout-tag {
  position: absolute; top: 8px; left: 8px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; border-radius: 6px; padding: 3px 8px;
}

/* panel pesanan */
.order-panel {
  width: var(--panel-w); flex: 0 0 auto; background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.order-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.order-head .row1 { display: flex; align-items: center; gap: 8px; }
.order-head .ono { font-weight: 800; font-size: 1rem; }
.order-head .muted { color: var(--ink-3); font-size: .8rem; }
.seg { display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; color: var(--ink-2); }
.seg button.active { background: var(--black); color: #fff; }
.order-items { flex: 1; overflow-y: auto; padding: 8px 12px; }
.oi { display: flex; gap: 10px; padding: 10px 6px; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.oi .nm { font-weight: 600; font-size: .9rem; }
.oi .opts { font-size: .76rem; color: var(--ink-3); margin-top: 2px; }
.oi .note { font-size: .76rem; color: var(--warn); margin-top: 2px; }
.oi .meta { flex: 1; min-width: 0; }
.oi .pr { font-weight: 700; font-size: .88rem; white-space: nowrap; }
.oi .sent { font-size: .68rem; color: var(--ok); font-weight: 700; }
.qty-ctl { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.qty-ctl button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  font-size: 1.05rem; font-weight: 700; display: grid; place-items: center;
}
.qty-ctl .q { min-width: 34px; text-align: center; font-weight: 700; }
.qty-ctl .note-btn { width: auto; padding: 0 8px; font-size: .72rem; font-weight: 600; color: var(--ink-2); }
.order-totals { border-top: 1px solid var(--line); padding: 10px 16px; font-size: .9rem; }
.order-totals .tr { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); }
.order-totals .tr.total { font-size: 1.2rem; font-weight: 800; color: var(--ink); padding-top: 8px; }
.order-actions { padding: 10px 16px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.order-actions .btn.big { grid-column: 1 / -1; }
.empty-state { text-align: center; color: var(--ink-3); padding: 40px 16px; }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 8px; color: #cfcfc2; }

/* ---------- grid meja ---------- */
.table-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.table-card { border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface); padding: 16px; text-align: left; }
.table-card .tn { font-weight: 800; font-size: 1.05rem; }
.table-card .ts { margin-top: 6px; font-size: .8rem; }
.table-card.kosong { border-color: var(--line); }
.table-card.terisi { border-color: var(--olive); background: var(--olive-soft); }
.table-card.menunggu { border-color: var(--warn); background: var(--warn-soft); }

/* ---------- dapur ---------- */
.kds-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-content: start; }
.kds-card { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.kds-card .hd { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: #fff; }
.kds-card .hd .t { font-weight: 800; }
.kds-card.queued .hd { background: var(--black); }
.kds-card.in_progress .hd { background: var(--warn); }
.kds-card.ready .hd { background: var(--olive); }
.kds-card ul { list-style: none; margin: 0; padding: 8px 14px; }
.kds-card li { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.kds-card li:last-child { border-bottom: 0; }
.kds-card li .q { font-weight: 800; margin-right: 8px; }
.kds-card li .o { display: block; font-size: .76rem; color: var(--ink-3); }
.kds-card li .n { display: block; font-size: .76rem; color: var(--warn); font-weight: 600; }
.kds-card .ft { padding: 10px 14px 14px; }
.kds-age { font-size: .76rem; opacity: .85; }

/* ---------- tabel data ---------- */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.data-table th { background: #f0f0e9; font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2); }
.data-table tr:hover td { background: #fafaf6; }
.data-table td.r, .data-table th.r { text-align: right; }

/* ---------- laporan ---------- */
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .lb { font-size: .76rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px; }
.stat .vl { font-size: 1.35rem; font-weight: 800; margin-top: 4px; }
.stat .sb { font-size: .76rem; color: var(--ink-3); margin-top: 2px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12,12,8,.5); display: grid; place-items: center;
  z-index: 50; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px;
  max-height: 92dvh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 760px; }
.modal .m-head { display: flex; align-items: center; padding: 16px 20px 8px; }
.modal .m-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.modal .m-body { padding: 10px 20px; overflow-y: auto; }
.modal .m-foot { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.x-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--bg); font-size: 1.1rem; }

/* opsi varian */
.opt-group { margin-bottom: 14px; }
.opt-group .gl { font-weight: 700; font-size: .9rem; margin-bottom: 8px; }
.opt-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-choice {
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: .88rem;
}
.opt-choice.active { border-color: var(--olive); background: var(--olive-soft); color: var(--olive-strong); }

/* pembayaran */
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.pay-methods button {
  min-height: 56px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.pay-methods button.active { border-color: var(--olive); background: var(--olive-soft); color: var(--olive-strong); }
.quick-cash { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pay-summary { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; font-size: .92rem; }
.pay-summary .tr { display: flex; justify-content: space-between; padding: 2px 0; }
.pay-summary .tr.total { font-weight: 800; font-size: 1.15rem; padding-top: 6px; }
.change-big { font-size: 1.5rem; font-weight: 800; color: var(--ok); }

/* ---------- toast & status ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--black); color: #fff; border-radius: 12px; padding: 12px 20px; font-size: .9rem;
  box-shadow: var(--shadow-lg); max-width: 90vw; animation: pop .18s ease;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
#offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: var(--danger); color: #fff;
  text-align: center; padding: 8px; font-size: .85rem; font-weight: 600;
}
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--olive);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-loading { text-align: center; color: var(--ink-3); padding: 40px; }

/* mobile cart FAB */
.cart-fab {
  display: none; position: fixed; right: 16px; bottom: 76px; z-index: 40;
  min-width: 56px; height: 56px; border-radius: 999px; background: var(--olive); color: #fff;
  border: 0; box-shadow: var(--shadow-lg); font-weight: 800; padding: 0 18px; align-items: center; gap: 8px;
  white-space: nowrap;
}

/* opsi editor menu */
.opt-editor { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 10px; }
.opt-editor .row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.opt-editor input { min-height: 38px; }

.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters-row .field { margin-bottom: 0; min-width: 140px; }

/* ---------- responsif ---------- */
@media (max-width: 1100px) {
  :root { --panel-w: 340px; --sidebar-w: 72px; }
  .sidebar .brand .tt, .nav button span, .sidebar .user .meta { display: none; }
  .sidebar .brand { justify-content: center; }
  .nav button { justify-content: center; padding: 0; }
  .sidebar .user { justify-content: center; }
}
@media (max-width: 820px) {
  #app { flex-direction: column; }
  .sidebar {
    width: 100%; order: 2; flex-direction: row; padding: 6px 8px;
    position: sticky; bottom: 0; align-items: center;
  }
  .sidebar .brand, .sidebar .foot .btn-logout-label { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .nav button { min-width: 62px; flex-direction: column; gap: 3px; font-size: .62rem; min-height: 52px; }
  .nav button span { display: block; }
  .sidebar .foot { border: 0; padding: 0; margin: 0; }
  .sidebar .user { display: none; }
  .main { order: 1; height: calc(100dvh - 66px); }
  .pos-layout { position: relative; }
  .order-panel {
    position: fixed; inset: 0; z-index: 45; width: 100%; transform: translateY(100%);
    transition: transform .25s ease; border-left: 0;
  }
  .order-panel.open { transform: translateY(0); }
  .order-panel .panel-close { display: inline-flex; }
  .cart-fab { display: inline-flex; }
  .prod-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
.order-panel .panel-close { display: none; }

/* ---------- cetak ---------- */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; left: 0; top: 0; }
}
