/*
 * NetPOS — bahasa visual.
 *
 * Dirancang untuk tangan yang sibuk, bukan untuk tangkapan layar: kasir memakai
 * ini berdiri, satu tangan memegang barang, di bawah lampu toko yang terang, dan
 * mengulanginya ratusan kali sehari. Karena itu tiap keputusan di bawah tunduk
 * pada tiga hal — sasaran sentuh besar, hierarki yang bisa dibaca sekilas, dan
 * ketenangan (tidak ada warna yang berteriak kecuali ia memang peringatan).
 */

:root {
  color-scheme: light dark;

  /* Satu skala warna netral hangat; aksen dipakai hemat supaya tetap berarti. */
  --ink: #0b0b0c;
  --ink-2: #3c3c43;
  --ink-3: #8a8a8e;
  --line: rgba(60, 60, 67, 0.14);
  --line-strong: rgba(60, 60, 67, 0.28);
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --accent: #0a7d5a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 125, 90, 0.1);
  --danger: #b3261e;
  --danger-soft: rgba(179, 38, 30, 0.1);
  --warn: #8a5a00;
  --warn-soft: rgba(138, 90, 0, 0.12);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-full: 999px;

  --shadow-1: 0 1px 2px rgba(11, 11, 12, 0.06), 0 1px 1px rgba(11, 11, 12, 0.04);
  --shadow-2: 0 8px 24px rgba(11, 11, 12, 0.1), 0 2px 6px rgba(11, 11, 12, 0.06);
  --shadow-3: 0 24px 60px rgba(11, 11, 12, 0.22);

  /* Satu tanda tangan gerak. Semua transisi memakai kurva ini supaya aplikasi
     terasa satu benda, bukan kumpulan komponen. */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --fast: 140ms;
  --base: 220ms;

  --touch: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f5f5f7;
    --ink-2: #c7c7cc;
    --ink-3: #8a8a8e;
    --line: rgba(235, 235, 245, 0.14);
    --line-strong: rgba(235, 235, 245, 0.26);
    --bg: #0b0b0c;
    --surface: #171719;
    --surface-2: #1f1f22;
    --accent: #2fbd8c;
    --accent-ink: #06231a;
    --accent-soft: rgba(47, 189, 140, 0.14);
    --danger: #ff6b60;
    --danger-soft: rgba(255, 107, 96, 0.14);
    --warn: #e0a54a;
    --warn-soft: rgba(224, 165, 74, 0.16);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Kasir tidak pernah bermaksud menyeleksi teks; seleksi tak sengaja saat
     menggeser daftar keranjang justru mengganggu. */
  user-select: none;
}

/* Angka uang: tabular supaya kolom rupiah tidak bergoyang saat berubah. */
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

.app { height: 100%; display: flex; flex-direction: column; }

/* ─── Bilah atas ─────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}

.topbar__title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar__sub { font-size: 13px; color: var(--ink-3); }
.topbar__spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.pill--live { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill--offline { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill--offline .pill__dot { animation: pulse 1.8s var(--ease) infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ─── Tata letak kasir ───────────────────────────────────────────────────── */

.till {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1px;
  background: var(--line);
  min-height: 0;
}

@media (max-width: 860px) {
  .till { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
}

.cart, .side { background: var(--bg); display: flex; flex-direction: column; min-height: 0; }

.cart__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 20px 10px;
}
.cart__title { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.cart__count { font-size: 14px; color: var(--ink-3); }

.lines { flex: 1; overflow-y: auto; padding: 0 12px 12px; -webkit-overflow-scrolling: touch; }

.line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  padding: 14px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  margin-bottom: 8px;
  animation: line-in var(--base) var(--ease);
}

@keyframes line-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.line__name { font-size: 16px; font-weight: 550; letter-spacing: -0.01em; }
.line__meta { grid-column: 1; font-size: 13px; color: var(--ink-3); }
.line__amount { grid-row: 1; grid-column: 2; font-size: 16px; font-weight: 600; }
.line__was { grid-column: 2; font-size: 13px; color: var(--ink-3); text-decoration: line-through; }
.line__promo {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 550;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: var(--r-full);
}

.line__qty {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  grid-column: 1;
}
.qtybtn {
  width: 34px; height: 34px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px; font-weight: 500;
  display: grid; place-items: center;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.qtybtn:active { transform: scale(0.92); background: var(--surface-2); }

.empty {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--ink-3);
  text-align: center;
  padding: 40px;
}
.empty__title { font-size: 17px; font-weight: 550; color: var(--ink-2); }
.empty__hint { font-size: 14px; max-width: 30ch; }

/* ─── Sisi kanan: total & tindakan ───────────────────────────────────────── */

.side { padding: 18px 16px calc(16px + var(--safe-b)); gap: 12px; }

/* Total menempel tepat di atas tombol bayar, bukan melayang di puncak kolom:
   mata kasir bergerak keranjang → total → bayar tanpa melompati rongga. */
.totals { background: var(--surface); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-1); margin-top: auto; }
.totals__row { display: flex; justify-content: space-between; font-size: 15px; color: var(--ink-2); padding: 3px 0; }
.totals__row--discount { color: var(--accent); }
.totals__grand { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.totals__label { font-size: 15px; font-weight: 550; }
.totals__value { font-size: 30px; font-weight: 680; letter-spacing: -0.03em; }
.totals__tax { margin-top: 8px; font-size: 12px; color: var(--ink-3); }

.actions { display: grid; gap: 8px; }
.actions__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn {
  min-height: var(--touch);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
  transition: transform var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.btn:active { transform: scale(0.975); }
.btn[disabled] { opacity: 0.4; }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-2); }
.btn--ghost { background: transparent; border-color: var(--line-strong); box-shadow: none; }
.btn--danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn--tall { min-height: 64px; font-size: 18px; }
.btn--wide { grid-column: 1 / -1; }

/* ─── Lembar (sheet) ─────────────────────────────────────────────────────── */

.scrim {
  position: fixed; inset: 0;
  background: rgba(11, 11, 12, 0.4);
  backdrop-filter: blur(3px);
  animation: fade var(--base) var(--ease);
  z-index: 40;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 100%);
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-3);
  padding: 8px 20px calc(20px + var(--safe-b));
  z-index: 41;
  max-height: 92vh;
  overflow-y: auto;
  animation: sheet-in var(--base) var(--ease);
}
@keyframes sheet-in { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.sheet__grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 6px auto 14px; }

/* Tombol utama lembar TIDAK BOLEH terdorong ke bawah lipatan. Di layar pendek —
   iPad mendatar dengan papan ketik terbuka — isi lembar lebih tinggi dari
   layarnya, dan tombol "Selesaikan" yang harus dicari dengan menggulir adalah
   antrean kasir yang berhenti. */
.sheet__actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 0 2px;
  background: linear-gradient(to bottom, transparent, var(--surface) 22%);
}
.sheet__title { font-size: 22px; font-weight: 660; letter-spacing: -0.02em; margin: 0 0 4px; }
.sheet__sub { font-size: 14px; color: var(--ink-3); margin: 0 0 18px; }

/* ─── Kolom masuk & papan angka ──────────────────────────────────────────── */

.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; font-weight: 550; color: var(--ink-2); margin-bottom: 6px; }
.input {
  width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  user-select: text;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.input--amount { font-size: 28px; font-weight: 640; letter-spacing: -0.02em; text-align: right; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.key {
  min-height: 60px;
  font-size: 24px;
  font-weight: 550;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.key:active { transform: scale(0.95); background: var(--line); }

.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 16px; }
.method {
  min-height: 60px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.method[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.method:active { transform: scale(0.97); }

/* ─── Pemindai ───────────────────────────────────────────────────────────── */

.scanner { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner__frame {
  position: absolute; inset: 18% 12%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
}
.scanner__hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #fff; font-size: 14px; }

/* ─── Masuk (PIN) ────────────────────────────────────────────────────────── */

.lock { flex: 1; display: grid; place-items: center; padding: 24px; }
.lock__card { width: min(420px, 100%); background: var(--surface); border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow-2); }
.lock__brand { font-size: 13px; font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.lock__title { font-size: 26px; font-weight: 680; letter-spacing: -0.03em; margin: 6px 0 2px; }
.lock__sub { font-size: 14px; color: var(--ink-3); margin-bottom: 20px; }

.pins { display: flex; gap: 10px; justify-content: center; margin: 18px 0 6px; }
.pins__dot { width: 13px; height: 13px; border-radius: 50%; background: var(--line-strong); transition: transform var(--fast) var(--ease), background var(--fast) var(--ease); }
.pins__dot--on { background: var(--accent); transform: scale(1.18); }

.people { display: grid; gap: 8px; margin-bottom: 18px; }
.person {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--touch);
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  text-align: left;
}
.person[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); }
.person__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 650;
}
.person__name { font-weight: 550; }
.person__role { font-size: 13px; color: var(--ink-3); }

/* ─── Pemberitahuan ──────────────────────────────────────────────────────── */

/* Pemberitahuan muncul di ATAS. Di bawah, ia menutupi tombol "Selesaikan" dan
   "Bayar" persis ketika kasir hendak menekannya. */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); display: grid; gap: 8px; z-index: 60; width: min(520px, calc(100% - 32px)); }
.toast {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  animation: toast-in var(--base) var(--ease);
}
.toast--error { background: var(--danger); color: #fff; }
.toast--ok { background: var(--accent); color: var(--accent-ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  font-size: 14px; font-weight: 500;
  background: var(--warn-soft); color: var(--warn);
}

/* Gerak dimatikan bagi yang memintanya lewat setelan perangkat. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
