/* ============================================================
   KASIR POS — "Ivory & Champagne" Light Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ============================================================
   Design tokens
   ============================================================ */
:root {
  /* Surfaces — warm ivory */
  --kd-bg:        oklch(0.974 0.006 85);
  --kd-bg-2:      oklch(0.962 0.007 82);
  --kd-surface:   oklch(1.000 0 0);
  --kd-surface-2: oklch(0.982 0.004 83);
  --kd-surface-3: oklch(0.962 0.008 80);
  --kd-hover:     oklch(0.948 0.010 78);

  /* Lines */
  --kd-line:      oklch(0.860 0.010 80 / 0.85);
  --kd-line-soft: oklch(0.860 0.010 80 / 0.55);
  --kd-hairline:  oklch(0.4 0.01 70 / 0.05);

  /* Text */
  --kd-ink:   oklch(0.148 0.014 55);
  --kd-ink-2: oklch(0.295 0.013 58);
  --kd-ink-3: oklch(0.450 0.010 65);
  --kd-ink-4: oklch(0.600 0.008 72);

  /* Champagne gold — deepened for light background contrast */
  --kd-gold:      oklch(0.620 0.128 70);
  --kd-gold-2:    oklch(0.560 0.122 67);
  --kd-gold-deep: oklch(0.500 0.115 64);
  --kd-gold-glow: oklch(0.640 0.125 72 / 0.22);
  --kd-gold-tint: oklch(0.640 0.125 72 / 0.09);

  /* Emerald — money/success */
  --kd-green:      oklch(0.520 0.145 162);
  --kd-green-2:    oklch(0.470 0.148 162);
  --kd-green-tint: oklch(0.520 0.145 162 / 0.10);

  /* Danger */
  --kd-red:      oklch(0.520 0.185 22);
  --kd-red-2:    oklch(0.465 0.188 22);
  --kd-red-tint: oklch(0.520 0.185 22 / 0.09);

  /* Misc */
  --kd-radius:    14px;
  --kd-radius-sm: 10px;
  --kd-radius-lg: 20px;
  --kd-shadow:    0 1px 2px oklch(0.4 0.01 70 / 0.06), 0 3px 8px oklch(0.4 0.01 70 / 0.05);
  --kd-shadow-md: 0 2px 4px oklch(0.4 0.01 70 / 0.07), 0 8px 20px oklch(0.4 0.01 70 / 0.06);
  --kd-shadow-lg: 0 4px 8px oklch(0.4 0.01 70 / 0.08), 0 16px 40px oklch(0.4 0.01 70 / 0.08);
  --kd-ring:      0 0 0 3px var(--kd-gold-glow);
  --kd-ease:      cubic-bezier(0.22, 0.61, 0.36, 1);
  --kd-ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --kd-sans:      'Plus Jakarta Sans', system-ui, sans-serif;
  --kd-mono:      'JetBrains Mono', ui-monospace, monospace;

  /* Legacy compat vars (referenced in some inline styles) */
  --gray-300: oklch(0.840 0.010 80);
  --gray-400: var(--kd-ink-4);
  --gray-600: var(--kd-ink-3);
  --danger:   var(--kd-red);
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: var(--kd-sans);
  background: var(--kd-bg);
  color: var(--kd-ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* Warm subtle vignette */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 70% at 100% 0%, oklch(0.640 0.125 72 / 0.05), transparent 50%),
    radial-gradient(100% 80% at 0% 100%, oklch(0.520 0.145 162 / 0.03), transparent 50%);
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--kd-gold-glow); color: var(--kd-ink); }

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--kd-line); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--kd-ink-4); }

.mono { font-family: var(--kd-mono); font-feature-settings: "tnum" 1; }

/* ============================================================
   Inline line-icons (lihat js/icons.js)
   ============================================================ */
.kd-ico {
  width: 1em; height: 1em; flex: none;
  display: inline-block; vertical-align: -0.135em;
  stroke: currentColor; color: inherit;
}
.kd-ico-chip {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--kd-gold-tint); color: var(--kd-gold-2);
}
.kd-ico-chip .kd-ico { width: 20px; height: 20px; }
.kd-ico-chip.is-green { background: var(--kd-green-tint); color: var(--kd-green-2); }
.kd-ico-chip.is-red   { background: var(--kd-red-tint);   color: var(--kd-red-2); }
.kd-ico-chip.is-muted { background: var(--kd-surface-3);  color: var(--kd-ink-3); }

/* ============================================================
   App shell
   ============================================================ */
.kd-app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Mobile overlay scrim — hidden by default on desktop */
.kd-scrim { display: none; }

/* ---- Sidebar ---- */
.kd-sidebar {
  display: flex; flex-direction: column;
  background: var(--kd-surface);
  border-right: 1px solid var(--kd-line-soft);
  padding: 18px 12px;
  gap: 4px;
  overflow-y: auto;
  z-index: 60;
}

.kd-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 8px 18px;
}
.kd-brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--kd-gold), var(--kd-gold-deep));
  color: oklch(1.0 0 0);
  font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 16px -6px var(--kd-gold-glow);
  flex-shrink: 0;
}
.kd-brand-name { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.kd-brand-sub { font-family: var(--kd-mono); font-size: 9.5px; letter-spacing: 0.16em; color: var(--kd-ink-4); text-transform: uppercase; }

.kd-nav-label {
  padding: 12px 10px 6px;
  font-family: var(--kd-mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--kd-ink-4);
}

.kd-nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--kd-radius-sm);
  color: var(--kd-ink-3);
  font-weight: 600; font-size: 14px;
  position: relative;
  transition: color 0.16s var(--kd-ease), background 0.16s var(--kd-ease), transform 0.1s var(--kd-ease);
  -webkit-tap-highlight-color: transparent;
}
.kd-nav-item svg { width: 19px; height: 19px; flex-shrink: 0; transition: transform 0.18s var(--kd-ease-out); }
.kd-nav-item:hover { color: var(--kd-ink); background: var(--kd-surface-2); }
.kd-nav-item:hover svg { transform: scale(1.06); }
.kd-nav-item:active { transform: scale(0.98); }
.kd-nav-item.active { color: var(--kd-gold); background: var(--kd-gold-tint); }
.kd-nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 20px; border-radius: 0 4px 4px 0;
  background: var(--kd-gold); box-shadow: 0 0 12px var(--kd-gold-glow);
}
.kd-nav-badge {
  margin-left: auto; font-family: var(--kd-mono); font-size: 10px; font-weight: 700;
  background: var(--kd-gold); color: oklch(1.0 0 0);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; display: grid; place-items: center;
}

.kd-sidebar-foot { margin-top: auto; padding: 12px 10px 4px; }
.kd-status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  background: var(--kd-surface-2);
  border: 1px solid var(--kd-line-soft);
  border-radius: var(--kd-radius-sm);
  font-size: 12px; color: var(--kd-ink-3);
}
.kd-dot {
  width: 7px; height: 7px; border-radius: 99px;
  background: var(--kd-green);
  animation: kd-ping 2.4s var(--kd-ease) infinite;
  flex-shrink: 0;
}
@keyframes kd-ping {
  0%   { box-shadow: 0 0 0 0 var(--kd-green-tint); }
  70%, 100% { box-shadow: 0 0 0 5px transparent; }
}

/* ---- Main column ---- */
.kd-main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.kd-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--kd-line-soft);
  flex-shrink: 0; background: var(--kd-surface);
}
.kd-topbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.kd-topbar-sub { color: var(--kd-ink-3); font-size: 12.5px; margin-top: 1px; }
.kd-topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Mobile top bar — hidden on desktop */
.kd-mobile-top { display: none; }

/* ============================================================
   Kasir split layout
   ============================================================ */
.kd-kasir-wrap {
  display: grid;
  grid-template-columns: 1fr 360px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ---- Left: product area ---- */
.kd-kasir-left { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.kd-toolbar {
  padding: 16px 20px 12px;
  display: flex; flex-direction: column; gap: 10px;
  flex-shrink: 0; border-bottom: 1px solid var(--kd-line-soft);
  background: var(--kd-surface);
}
.kd-toolbar-row { display: flex; align-items: center; gap: 10px; }
.kd-search-wrap { flex: 1; position: relative; display: flex; align-items: center; }
.kd-search-wrap svg {
  position: absolute; left: 12px; width: 18px; height: 18px;
  color: var(--kd-ink-4); pointer-events: none; flex-shrink: 0;
}
.kd-search-input {
  width: 100%; padding: 10px 14px 10px 38px;
  background: var(--kd-surface-2);
  border: 1px solid var(--kd-line-soft);
  border-radius: var(--kd-radius-sm);
  font-size: 14px; color: var(--kd-ink);
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.kd-search-input::placeholder { color: var(--kd-ink-4); }
.kd-search-input:focus { outline: none; border-color: var(--kd-gold); box-shadow: var(--kd-ring); background: var(--kd-surface); }

/* Category chips */
.kd-chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.kd-chips::-webkit-scrollbar { display: none; }
.kd-chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 99px;
  background: var(--kd-surface-2); border: 1px solid var(--kd-line-soft);
  color: var(--kd-ink-3); font-size: 12.5px; font-weight: 600;
  transition: all 0.15s var(--kd-ease); white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.kd-chip:hover { color: var(--kd-ink); border-color: var(--kd-line); background: var(--kd-surface-3); }
.kd-chip:active { transform: scale(0.96); }
.kd-chip.active {
  background: var(--kd-gold); color: oklch(1.0 0 0); border-color: var(--kd-gold);
  box-shadow: 0 4px 12px -6px var(--kd-gold-glow);
}

/* Alert / Loading */
.kd-alerts { flex-shrink: 0; }
.alert { padding: 10px 16px; font-size: 13.5px; font-weight: 600; border-radius: var(--kd-radius-sm); margin: 8px 20px 0; }
.alert-error { background: var(--kd-red-tint); color: var(--kd-red); border: 1px solid oklch(0.520 0.185 22 / 0.2); }
.alert-success { background: var(--kd-green-tint); color: var(--kd-green); border: 1px solid oklch(0.520 0.145 162 / 0.2); }

.kd-loading {
  padding: 8px 20px; font-size: 13px; color: var(--kd-ink-3); flex-shrink: 0;
}
.kd-loading::before {
  content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 99px;
  border: 2px solid var(--kd-gold-tint); border-top-color: var(--kd-gold);
  animation: kd-spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px;
}
@keyframes kd-spin { to { transform: rotate(360deg); } }

/* Hide print-method-info when empty */
.print-method-info:empty { display: none; }

/* Product scroll area */
.kd-scroll { flex: 1; overflow-y: auto; padding: 16px 20px; min-height: 0; }

/* Product grid */
.kd-product-grid, #product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* Product cards — dynamically rendered by kasir.js */
.product-item {
  position: relative; text-align: left;
  padding: 14px; border-radius: var(--kd-radius-sm);
  background: var(--kd-surface);
  border: 1px solid var(--kd-line-soft);
  box-shadow: var(--kd-shadow);
  transition: transform 0.15s var(--kd-ease), border-color 0.16s, box-shadow 0.18s, background 0.16s;
  overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 116px;
}
.product-item:hover {
  transform: translateY(-2px);
  border-color: var(--kd-gold);
  box-shadow: var(--kd-shadow-md), 0 0 0 0 transparent;
  background: var(--kd-surface-2);
}
.product-item:active { transform: scale(0.97); }
.product-item.flash {
  animation: kd-prod-flash 0.5s var(--kd-ease);
}
@keyframes kd-prod-flash {
  0%   { box-shadow: 0 0 0 0 var(--kd-gold-glow), var(--kd-shadow); border-color: var(--kd-gold); }
  100% { box-shadow: 0 0 0 8px transparent, var(--kd-shadow); border-color: var(--kd-line-soft); }
}

.product-item.has-varian::after {
  content: "Varian";
  position: absolute; top: 10px; right: 10px;
  font-family: var(--kd-mono); font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
  padding: 2px 6px; border-radius: 5px;
  background: var(--kd-gold-tint); color: var(--kd-gold);
  border: 1px solid oklch(0.640 0.125 72 / 0.2);
}

.product-name {
  font-weight: 700; font-size: 13.5px; letter-spacing: -0.01em; line-height: 1.3;
  color: var(--kd-ink); padding-right: 40px;
}
.product-item.has-varian .product-name { padding-right: 48px; }
.product-price {
  font-family: var(--kd-mono); font-weight: 700; font-size: 14px;
  color: var(--kd-gold); margin-top: auto;
}
.product-stock { font-size: 11px; color: var(--kd-ink-4); }
.product-price-date { font-size: 10.5px; color: var(--kd-ink-4); }

/* Bottom add button bar */
.kd-bottom-bar {
  padding: 12px 20px; flex-shrink: 0;
  border-top: 1px solid var(--kd-line-soft);
  background: var(--kd-surface);
}

/* ============================================================
   Cart rail (right panel, #modal-cart)
   On desktop: always visible as the right rail (display: flex !important)
   On mobile: kasir.js controls display normally (overlay/sheet)
   ============================================================ */
#modal-cart {
  flex-direction: column;
  background: var(--kd-surface);
  overflow: hidden;
  min-height: 0;
}

.kd-cart-head {
  padding: 18px 20px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--kd-line-soft);
}
.kd-cart-title-row {
  display: flex; align-items: center; gap: 10px;
}
.kd-cart-head h2 { font-size: 16px; font-weight: 800; }
.kd-cart-close {
  margin-left: auto; display: none;  /* hidden on desktop */
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--kd-surface-2); border: 1px solid var(--kd-line-soft);
  color: var(--kd-ink-3); font-size: 18px; line-height: 1;
  transition: all 0.14s; display: grid; place-items: center;
}
.kd-cart-close:hover { background: var(--kd-red-tint); color: var(--kd-red); }

.kd-cart-customer { padding: 12px 20px 8px; flex-shrink: 0; }

.kd-cart-scroll {
  flex: 1; overflow-y: auto; padding: 4px 20px;
  min-height: 0;
}

/* Cart items — dynamically rendered by kasir.js */
.cart-item {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--kd-line-soft);
}
.cart-item:last-child { border-bottom: none; }

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 700; font-size: 13px; letter-spacing: -0.01em; color: var(--kd-ink); }
.cart-item-catatan-row { display: flex; align-items: center; gap: 5px; margin-top: 3px; min-width: 0; }
.cart-item-catatan { font-size: 11px; color: var(--kd-gold-2); font-style: italic; flex: 1; min-width: 0; word-break: break-all; overflow-wrap: break-word; }
.btn-edit-catatan {
  width: 22px; height: 22px; border-radius: 6px; font-size: 11px;
  background: transparent; color: var(--kd-ink-4);
  display: grid; place-items: center;
  transition: background 0.13s, color 0.13s;
}
.btn-edit-catatan:hover { background: var(--kd-gold-tint); color: var(--kd-gold); }
.cart-item-price {
  display: flex; align-items: center; gap: 4px;
  font-family: var(--kd-mono); font-size: 12px; color: var(--kd-ink-3); margin-top: 3px;
}
.btn-edit-price {
  width: 20px; height: 20px; border-radius: 5px; font-size: 11px;
  background: transparent; color: var(--kd-ink-4);
  display: grid; place-items: center;
  transition: background 0.13s, color 0.13s;
}
.btn-edit-price:hover { background: var(--kd-gold-tint); color: var(--kd-gold); }

.cart-item-qty {
  display: flex; align-items: center; gap: 0;
  background: var(--kd-surface-2); border: 1px solid var(--kd-line);
  border-radius: 8px; overflow: hidden;
}
.qty-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  color: var(--kd-ink-3); font-size: 16px; font-weight: 600;
  transition: background 0.13s, color 0.13s;
}
.qty-btn:hover { background: var(--kd-gold-tint); color: var(--kd-gold); }
.qty-btn:active { transform: scale(0.88); }
.qty-value {
  width: 28px; text-align: center;
  font-family: var(--kd-mono); font-weight: 700; font-size: 13px;
}

.cart-item-subtotal {
  font-family: var(--kd-mono); font-weight: 700; font-size: 13px;
  color: var(--kd-ink); align-self: center;
}
.btn-remove {
  width: 26px; height: 26px; border-radius: 7px; font-size: 16px; line-height: 1;
  color: var(--kd-ink-4); display: grid; place-items: center;
  transition: color 0.13s, background 0.13s;
  align-self: center;
}
.btn-remove:hover { color: var(--kd-red); background: var(--kd-red-tint); }

/* Cart empty state */
.cart-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 180px; color: var(--kd-ink-4); gap: 8px; text-align: center;
  font-size: 13.5px;
}

.kd-cart-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--kd-line);
  flex-shrink: 0;
  background: var(--kd-surface-2);
}
.kd-cart-total-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.kd-cart-total-row .lbl {
  font-family: var(--kd-mono); font-size: 11px; letter-spacing: 0.14em;
  color: var(--kd-ink-3); text-transform: uppercase;
}
.kd-cart-total-row .amt {
  font-family: var(--kd-mono); font-weight: 700; font-size: 24px;
  letter-spacing: -0.02em; color: var(--kd-gold);
  transition: transform 0.18s var(--kd-ease-out);
}
.kd-cart-total-row .amt.bump { animation: kd-bump 0.3s var(--kd-ease-out); }
@keyframes kd-bump { 30% { transform: scale(1.08); } }

.kd-cart-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

/* Cart hold orders list uses .cart-item too — style the buttons inside */
#hold-orders-list .btn {
  padding: 6px 12px; border-radius: var(--kd-radius-sm); font-size: 12.5px; font-weight: 700;
  transition: all 0.14s;
}
#hold-orders-list .btn-primary { background: var(--kd-gold); color: oklch(1.0 0 0); border: none; }
#hold-orders-list .btn-primary:hover { background: var(--kd-gold-2); }
#hold-orders-list .btn-danger { background: var(--kd-red-tint); color: var(--kd-red); border: 1px solid transparent; }
#hold-orders-list .btn-danger:hover { background: var(--kd-red); color: white; }

/* ============================================================
   Buttons
   ============================================================ */
.kd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px;
  border-radius: var(--kd-radius-sm);
  font-weight: 700; font-size: 13.5px;
  letter-spacing: -0.01em;
  transition: transform 0.1s var(--kd-ease), background 0.16s, box-shadow 0.18s, border-color 0.16s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.kd-btn svg { width: 17px; height: 17px; }
.kd-btn:active { transform: scale(0.965); }

.kd-btn-gold {
  background: linear-gradient(155deg, var(--kd-gold), var(--kd-gold-2));
  color: oklch(1.0 0 0);
  box-shadow: 0 6px 18px -8px var(--kd-gold-glow);
}
.kd-btn-gold:hover { box-shadow: 0 10px 24px -8px var(--kd-gold-glow); transform: translateY(-1px); }
.kd-btn-gold:active { transform: scale(0.965); }

.kd-btn-green {
  background: linear-gradient(155deg, var(--kd-green), var(--kd-green-2));
  color: oklch(1.0 0 0);
  box-shadow: 0 6px 18px -8px var(--kd-green-tint);
}
.kd-btn-green:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -8px var(--kd-green-tint); }
.kd-btn-green:active { transform: scale(0.965); }
.kd-btn-green:disabled { opacity: 0.45; pointer-events: none; }

.kd-btn-ghost {
  background: var(--kd-surface-2); color: var(--kd-ink);
  border: 1px solid var(--kd-line);
}
.kd-btn-ghost:hover { background: var(--kd-surface-3); border-color: var(--kd-line); }

.kd-btn-outline {
  background: transparent; color: var(--kd-gold);
  border: 1px solid var(--kd-gold);
}
.kd-btn-outline:hover { background: var(--kd-gold-tint); }

.kd-btn-line {
  background: transparent; color: var(--kd-ink-2);
  border: 1px solid var(--kd-line);
}
.kd-btn-line:hover { color: var(--kd-ink); border-color: var(--kd-ink-4); background: var(--kd-surface-2); }
.kd-btn-line:disabled { opacity: 0.4; pointer-events: none; }

.kd-btn-danger {
  background: var(--kd-red-tint); color: var(--kd-red);
  border: 1px solid oklch(0.520 0.185 22 / 0.2);
}
.kd-btn-danger:hover { background: var(--kd-red); color: white; border-color: var(--kd-red); }

.kd-btn-block { width: 100%; }
.kd-btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.kd-btn-lg { padding: 13px 20px; font-size: 15px; }

.kd-icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--kd-surface-2); border: 1px solid var(--kd-line-soft);
  color: var(--kd-ink-3);
  transition: transform 0.1s var(--kd-ease), background 0.16s, color 0.16s;
}
.kd-icon-btn svg { width: 18px; height: 18px; }
.kd-icon-btn:hover { color: var(--kd-ink); background: var(--kd-surface-3); border-color: var(--kd-line); }
.kd-icon-btn:active { transform: scale(0.92); }

/* Tag / Badge */
.kd-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--kd-mono); font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px;
  background: var(--kd-surface-2); color: var(--kd-ink-3); border: 1px solid var(--kd-line-soft);
}
.kd-tag-gold { background: var(--kd-gold-tint); color: var(--kd-gold); border-color: oklch(0.640 0.125 72 / 0.2); }
.kd-tag-green { background: var(--kd-green-tint); color: var(--kd-green); border-color: oklch(0.520 0.145 162 / 0.2); }

/* ============================================================
   Form inputs (used in modals and inline)
   ============================================================ */
.kd-input, .kd-select, .kd-textarea {
  width: 100%; padding: 11px 13px;
  background: var(--kd-surface-2);
  border: 1px solid var(--kd-line);
  border-radius: var(--kd-radius-sm);
  color: var(--kd-ink); font-size: 14px;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.kd-input::placeholder, .kd-textarea::placeholder { color: var(--kd-ink-4); }
.kd-input:focus, .kd-select:focus, .kd-textarea:focus {
  outline: none; border-color: var(--kd-gold); box-shadow: var(--kd-ring);
  background: var(--kd-surface);
}
.kd-input[readonly], .kd-input:read-only {
  background: var(--kd-surface-3); color: var(--kd-ink-3); cursor: default;
}
.kd-select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
  background-color: var(--kd-surface-2);
}

.kd-field { margin-bottom: 14px; }
.kd-field label, .kd-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--kd-ink-3); margin-bottom: 6px; letter-spacing: 0.01em;
}

.kd-check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--kd-ink-2); }
.kd-check input[type="checkbox"] {
  appearance: none; width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--kd-line); background: var(--kd-surface-2);
  display: grid; place-items: center; transition: all 0.14s; flex-shrink: 0; cursor: pointer;
}
.kd-check input[type="checkbox"]:checked { background: var(--kd-gold); border-color: var(--kd-gold); }
.kd-check input[type="checkbox"]:checked::after { content: "✓"; color: white; font-size: 12px; font-weight: 800; }

/* ============================================================
   Modals
   ============================================================ */
.kd-modal {
  position: fixed; inset: 0; z-index: 100;
  background: oklch(0.15 0.008 70 / 0.30);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.kd-modal-box {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: var(--kd-surface);
  border: 1px solid var(--kd-line-soft);
  border-radius: var(--kd-radius-lg);
  box-shadow: var(--kd-shadow-lg);
  animation: kd-modal-in 0.28s var(--kd-ease-out) both;
}
@keyframes kd-modal-in {
  from { transform: translateY(18px) scale(0.97); }
  to   { transform: none; }
}
.kd-modal-sm .kd-modal-box { max-width: 400px; }
.kd-modal-lg .kd-modal-box { max-width: 600px; }

.kd-modal-head {
  display: flex; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid var(--kd-line-soft);
}
.kd-modal-head h3 { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.kd-modal-head .kd-icon-btn { margin-left: auto; width: 32px; height: 32px; }

.kd-modal-body { padding: 20px; }
.kd-modal-foot {
  display: flex; gap: 9px;
  padding: 14px 20px; border-top: 1px solid var(--kd-line-soft);
}
.kd-modal-foot .kd-btn { flex: 1; }

/* Qty big selector (qty-select modal) */
.kd-qty-big {
  display: flex; align-items: center; justify-content: center; gap: 16px; margin: 18px 0;
}
.kd-qty-big button {
  width: 48px; height: 48px; border-radius: 13px;
  background: var(--kd-surface-2); border: 1px solid var(--kd-line);
  color: var(--kd-ink); font-size: 20px; font-weight: 600;
  display: grid; place-items: center;
  transition: all 0.13s var(--kd-ease);
}
.kd-qty-big button:hover { background: var(--kd-gold-tint); color: var(--kd-gold); border-color: var(--kd-gold); }
.kd-qty-big button:active { transform: scale(0.9); }
.kd-qty-big input {
  width: 78px; text-align: center;
  font-family: var(--kd-mono); font-weight: 700; font-size: 28px;
  background: transparent; border: none; color: var(--kd-ink);
}
.kd-qty-big input:focus { outline: none; }

.kd-subtotal-chip {
  text-align: center; padding: 12px; border-radius: var(--kd-radius-sm);
  background: var(--kd-green-tint); color: var(--kd-green);
  font-family: var(--kd-mono); font-weight: 700; font-size: 17px;
  border: 1px solid oklch(0.520 0.145 162 / 0.2);
}

/* Variant options (varian-select modal) */
.varian-option {
  padding: 12px 14px; border-radius: var(--kd-radius-sm);
  background: var(--kd-surface-2); border: 1px solid var(--kd-line-soft);
  cursor: pointer; transition: all 0.15s var(--kd-ease); margin-bottom: 8px;
}
.varian-option:hover { border-color: var(--kd-gold); background: var(--kd-surface-3); transform: translateX(3px); }
.varian-option:active { transform: scale(0.98); }
.varian-name { font-weight: 700; font-size: 14px; color: var(--kd-ink); }
.varian-price { font-family: var(--kd-mono); font-weight: 700; color: var(--kd-gold); font-size: 13.5px; margin-top: 2px; }
.varian-stock { font-size: 11.5px; color: var(--kd-ink-4); margin-top: 2px; }
.price-date-badge {
  font-size: 10px; color: var(--kd-ink-4); margin-left: 4px;
}

/* Print method options (print-method modal) */
.print-method-options { display: flex; flex-direction: column; gap: 9px; }
.btn-print-method {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; border-radius: var(--kd-radius-sm);
  background: var(--kd-surface-2); border: 1px solid var(--kd-line);
  text-align: left; transition: all 0.15s var(--kd-ease);
}
.btn-print-method:hover { border-color: var(--kd-gold); background: var(--kd-gold-tint); transform: translateY(-2px); }
.btn-print-method:active { transform: scale(0.98); }
.btn-print-method .icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--kd-gold-tint); color: var(--kd-gold); font-size: 20px; flex-shrink: 0;
}
.btn-print-method.btn-print-station .icon { background: var(--kd-surface-3); }
.btn-print-method.btn-share-wa .icon { background: var(--kd-green-tint) !important; color: var(--kd-green) !important; }
.btn-print-method .label { font-weight: 700; font-size: 13.5px; color: var(--kd-ink); }
.btn-print-method .desc { font-size: 11.5px; color: var(--kd-ink-3); margin-top: 1px; }

/* Print method info */
.print-method-info {
  background: var(--kd-surface-2); border-radius: var(--kd-radius-sm);
  padding: 12px 14px; margin-bottom: 14px;
  font-family: var(--kd-mono); font-size: 13px; font-weight: 600;
  color: var(--kd-green); text-align: center;
  border: 1px solid var(--kd-green-tint);
}

/* ============================================================
   Mobile FAB (cart floating button)
   ============================================================ */
#btn-cart-float {
  display: none;
  position: fixed; right: 18px; bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 45;
  height: 52px; padding: 0 18px 0 16px; border-radius: 99px; gap: 10px;
  background: linear-gradient(155deg, var(--kd-gold), var(--kd-gold-2));
  color: oklch(1.0 0 0);
  align-items: center; font-weight: 800; font-size: 14.5px;
  box-shadow: 0 10px 28px -8px var(--kd-gold-glow);
  transition: transform 0.14s var(--kd-ease);
}
#btn-cart-float svg { width: 20px; height: 20px; }
#btn-cart-float:active { transform: scale(0.94); }
.kd-fab-badge {
  font-family: var(--kd-mono); background: oklch(1.0 0 0); color: var(--kd-gold);
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
#cart-badge { /* legacy ID mapped to kd-fab-badge */ }

/* Mobile bottom tab bar */
.kd-tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: oklch(0.995 0.002 85 / 0.90);
  backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid var(--kd-line-soft);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.kd-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 2px; color: var(--kd-ink-4); font-size: 10px; font-weight: 600;
  border-radius: 10px; transition: color 0.16s var(--kd-ease);
  -webkit-tap-highlight-color: transparent;
}
.kd-tab svg { width: 22px; height: 22px; transition: transform 0.2s var(--kd-ease-out); }
.kd-tab.active { color: var(--kd-gold); }
.kd-tab.active svg { transform: translateY(-2px) scale(1.06); }

/* ============================================================
   Mobile responsive
   ============================================================ */
/* Desktop: cart always visible as right rail */
@media (min-width: 1025px) {
  #modal-cart {
    display: flex !important;
    border-left: 1px solid var(--kd-line-soft);
  }
  .kd-cart-close { display: none !important; }
}

@media (max-width: 1024px) {
  .kd-app { grid-template-columns: 1fr; }

  .kd-sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 60;
    transform: translateX(-104%);
    transition: transform 0.32s var(--kd-ease-out);
    box-shadow: none;
  }
  .kd-sidebar.open {
    transform: none;
    box-shadow: 0 0 60px oklch(0.4 0.01 70 / 0.15);
  }

  .kd-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: oklch(0.15 0.008 70 / 0.30);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.28s;
  }
  .kd-scrim.show { opacity: 1; pointer-events: auto; }

  .kd-topbar { display: none; }

  .kd-mobile-top {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--kd-line-soft);
    flex-shrink: 0; background: var(--kd-surface);
  }
  .kd-mobile-top h1 { font-size: 15.5px; font-weight: 800; }
  .kd-menu-toggle {
    width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
    background: var(--kd-surface-2); border: 1px solid var(--kd-line-soft);
    color: var(--kd-ink-2);
  }
  .kd-menu-toggle svg { width: 18px; height: 18px; }

  .kd-kasir-wrap { grid-template-columns: 1fr; }

  /* Mobile cart: position as full-screen overlay; kasir.js sets display: flex when showing */
  #modal-cart {
    position: fixed !important;
    inset: 0 !important;
    z-index: 80 !important;
    border-left: none !important;
    background: var(--kd-bg) !important;
    overflow: hidden;
  }
  /* Show close button on mobile */
  .kd-cart-close { display: grid !important; }

  /* Mobile FAB: shown always (hidden if no items by JS could use has-items class) */
  #btn-cart-float { display: flex; }

  .kd-tabbar { display: flex; }
  .kd-scroll { padding-bottom: 80px; }

  /* Cart footer: push content above Android nav bar (safe area) */
  .kd-cart-foot {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  /* Hide tabbar and FAB when sidebar is open */
  body.kd-sidebar-open .kd-tabbar,
  body.kd-sidebar-open #btn-cart-float { display: none !important; }

  /* Hide tabbar and FAB when cart is open */
  body.kd-cart-open .kd-tabbar,
  body.kd-cart-open #btn-cart-float { display: none !important; }
}

@media (max-width: 560px) {
  .kd-product-grid, #product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
  }
  .kd-modal-foot { flex-wrap: wrap; }
}

/* ============================================================
   Utility
   ============================================================ */
.kd-hidden { display: none !important; }
.kd-text-muted { color: var(--kd-ink-3); font-size: 12px; margin-top: 4px; }
.kd-divider { border: none; border-top: 1px solid var(--kd-line-soft); margin: 16px 0; }

/* ============================================================
   Print styles — thermal 58mm receipt
   ============================================================ */
#receipt-area {
  display: none; visibility: hidden; position: absolute; left: -9999px;
}

@media print {
  @page { size: 58mm auto !important; margin: 0 !important; }

  html, body {
    width: 48mm !important; height: auto !important;
    margin: 0 !important; padding: 0 !important;
    background: white !important; overflow: visible !important;
  }
  body::before { display: none !important; }

  body > *:not(#receipt-area) {
    display: none !important; visibility: hidden !important;
    width: 0 !important; height: 0 !important; overflow: hidden !important;
    position: absolute !important; left: -9999px !important;
  }

  #receipt-area {
    display: block !important; visibility: visible !important;
    position: static !important; left: auto !important;
    width: 48mm !important; max-width: 48mm !important;
    margin: 0 !important; padding: 1mm 2mm !important;
    background: white !important; overflow: visible !important;
  }
  #receipt-area * {
    visibility: visible !important; position: static !important; left: auto !important;
  }
  #receipt-area .rcp-head,
  #receipt-area .rcp-item,
  #receipt-area .rcp-total,
  #receipt-area .rcp-foot {
    page-break-inside: avoid !important; break-inside: avoid !important;
  }
}
