/* ============================================
   KASIR CANGGIH — Design Tokens
   Konsep: identitas visual "warung modern" —
   signage toko + struk kertas kasir sebagai motif utama.
   ============================================ */

:root {
  /* Warna */
  --ink: #1b2a4a;          /* navy dalam - header, teks penting */
  --ink-soft: #33456b;
  --paper: #faf7f0;        /* latar utama, warna kertas */
  --paper-card: #ffffff;
  --gold: #e8a93d;         /* aksen signage/harga */
  --gold-soft: #fbe3b8;
  --green: #2f8f5b;        /* tambah / konfirmasi */
  --green-soft: #e3f3ea;
  --red: #d8483a;          /* hapus / batal */
  --red-soft: #fbe6e3;
  --text: #23262b;
  --muted: #8a8578;
  --line: #e7e1d3;

  /* Tipografi */
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Plus Jakarta Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* Ukuran */
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(27, 42, 74, 0.08);
  --shadow-lift: 0 8px 24px rgba(27, 42, 74, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}

/* ---------- Header ---------- */
.topbar {
  background: var(--ink);
  color: white;
  padding: 14px 16px 12px;
  flex-shrink: 0;
}

.topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.brand .dot { color: var(--gold); }

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-wrap {
  flex: 1;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-family: var(--font-body);
  background: white;
  color: var(--text);
}

.search-wrap input::placeholder { color: var(--muted); }

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.12s ease;
}

.icon-btn svg { width: 22px; height: 22px; }

.icon-btn.scan { background: var(--gold); color: var(--ink); }
.icon-btn.voice { background: var(--ink-soft); color: white; }
.icon-btn.voice.listening {
  background: var(--red);
  animation: pulse 1.1s infinite;
}

.icon-btn:active { transform: scale(0.92); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(216, 72, 58, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(216, 72, 58, 0); }
}

.voice-status {
  font-size: 12.5px;
  color: var(--gold-soft);
  margin-top: 6px;
  min-height: 16px;
  font-style: italic;
}

/* ---------- Kategori chip ---------- */
.chips {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}

.chip.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

/* ---------- Daftar produk ---------- */
.product-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 130px;
}

.product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-card);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.product-info { flex: 1; min-width: 0; }

.product-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.product-price {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  margin-top: 3px;
}

.add-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.add-btn:active { transform: scale(0.88); }

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-soft);
  border-radius: 999px;
  padding: 4px;
}
.qty-stepper button {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.qty-stepper .qty-val {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 14px;
  line-height: 1.6;
}
.empty-state .big { font-size: 34px; display: block; margin-bottom: 8px; }

/* ---------- Struk / Total bar (signature element) ---------- */
.receipt-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--ink);
  color: white;
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lift);
  z-index: 10;
}

.receipt-bar::before {
  content: "";
  position: absolute;
  top: -9px; left: 0; right: 0;
  height: 10px;
  background:
    linear-gradient(-45deg, var(--paper) 6px, transparent 0) 0 0,
    linear-gradient(45deg, var(--paper) 6px, var(--ink) 0) 0 0;
  background-size: 14px 10px;
  background-repeat: repeat-x;
}

.receipt-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
}

.receipt-summary .label {
  font-size: 12px;
  color: var(--gold-soft);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 2px;
}

.receipt-summary .count {
  font-size: 12.5px;
  color: rgba(255,255,255,0.7);
}

.receipt-summary .total {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 24px;
  color: white;
}

.checkout-btn {
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.checkout-btn:active { transform: scale(0.96); }
.checkout-btn:disabled { opacity: 0.4; }

/* ---------- Scanner overlay ---------- */
.scanner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 42, 74, 0.96);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.scanner-overlay.hidden { display: none; }
.scanner-overlay #reader {
  width: 100%;
  max-width: 340px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 3px solid var(--gold);
}
.scanner-overlay p {
  color: white;
  font-size: 13px;
  margin-top: 16px;
  text-align: center;
}
.scanner-close {
  margin-top: 18px;
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 22px;
  border: 1px solid var(--gold);
  border-radius: 999px;
}

/* ---------- Checkout modal ---------- */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 42, 74, 0.5);
  z-index: 40;
  display: flex;
  align-items: flex-end;
}
.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: var(--paper-card);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 82vh;
  overflow-y: auto;
}

.modal-sheet h2 {
  font-family: var(--font-display);
  margin: 0 0 4px;
  font-size: 19px;
  color: var(--ink);
}

.modal-sheet .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
}

.cart-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.cart-row .name { font-weight: 600; flex: 1; }
.cart-row .calc { font-family: var(--font-mono); color: var(--muted); font-size: 12px; }
.cart-row .line-total { font-family: var(--font-mono); font-weight: 700; color: var(--ink); }
.cart-row .rm { color: var(--red); font-size: 18px; padding: 4px 8px; }

.totals-block {
  margin-top: 14px;
  padding-top: 10px;
}
.totals-block .row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 5px 0;
  color: var(--muted);
}
.totals-block .row.grand {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--font-mono);
  border-top: 2px solid var(--ink);
  margin-top: 6px;
  padding-top: 10px;
}

.pay-btn {
  width: 100%;
  background: var(--green);
  color: white;
  font-weight: 700;
  font-size: 15px;
  padding: 15px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}
.pay-btn:active { transform: scale(0.98); }

.close-modal {
  position: absolute;
  top: 14px; right: 16px;
  font-size: 22px;
  color: var(--muted);
}

.toast {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(6px);
}

/* ---------- Tombol tambah produk (FAB) ---------- */
.fab {
  position: absolute;
  right: 16px;
  bottom: 108px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lift);
  z-index: 15;
}
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(0.92); }

/* ---------- Form Tambah/Edit Produk ---------- */
.field-block { margin-bottom: 14px; }
.field-block label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.field-block input {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-size: 14.5px;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
}
.field-block input:focus { border-color: var(--gold); }

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.field-row input { flex: 1; }

.icon-btn.sm { width: 40px; height: 40px; flex-shrink: 0; }
.icon-btn.sm svg { width: 18px; height: 18px; }

.half-row {
  display: flex;
  gap: 12px;
}
.half-row > div { flex: 1; }

.lookup-status {
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
  color: var(--muted);
}
.lookup-status.found { color: var(--green); font-weight: 600; }
.lookup-status.notfound { color: var(--muted); }
.lookup-status.duplicate { color: var(--red); font-weight: 600; }
.lookup-status.loading { color: var(--gold); }

.voice-status.dark {
  color: var(--ink-soft);
  font-style: italic;
  margin: 4px 0 10px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
