/* ============================================================================
   WarungOS — Clean Modern POS Design System (Inspired by User's References)
   Palette: Crisp White Surface, Soft Slate Background, Signature Teal (#0D9488)
   Icons: 100% Microsoft Fluent UI System Icons
   ============================================================================ */
:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;
  --border: #E5E9F0;
  --text: #111827;
  --text-muted: #64748B;
  --primary: #0D9488;
  --primary-hover: #0F766E;
  --primary-soft: #E6F7F5;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --warning: #D97706;
  --warning-soft: #FFFBEB;
  --success: #16A34A;
  --success-soft: #F0FDF4;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --sidebar-w: 84px;
  --cart-w: 360px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: transparent; }
.hidden { display: none !important; }
.fluent-icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------- Auth Screen ---------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at top right, #CCFBF1 0%, #F4F6F8 55%);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px;
  padding: 32px; box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-logo {
  width: 46px; height: 46px; border-radius: 12px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px;
}
.auth-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.auth-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.auth-demo-box {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-alt); border: 1px dashed var(--border); font-size: 12px; color: var(--text-muted);
}
.auth-demo-btns { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- Main App Shell ---------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* Left Sidebar (Reference Image 1 Style) */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 14px 8px; gap: 6px; z-index: 20;
}
.brand-badge {
  width: 46px; height: 46px; border-radius: 12px; background: #111827; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px;
  margin-bottom: 10px; position: relative;
}
.brand-badge span { color: #2DD4BF; }
.nav-list { display: flex; flex-direction: column; gap: 4px; width: 100%; flex: 1; overflow-y: auto; }
.nav-btn {
  width: 100%; padding: 10px 4px; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; gap: 4px; color: var(--text-muted); font-size: 11px; font-weight: 500;
  transition: all 0.15s ease;
}
.nav-btn:hover { background: var(--surface-alt); color: var(--text); }
.nav-btn.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-footer { width: 100%; border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }

/* Main Content Area */
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* Topbar */
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 12px; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { font-size: 18px; font-weight: 700; white-space: nowrap; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--success-soft); color: var(--success);
}
.status-pill.offline { background: var(--warning-soft); color: var(--warning); }
.role-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary);
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Views Container */
.view-container { flex: 1; overflow: hidden; display: flex; }
.view-scroll { flex: 1; overflow-y: auto; padding: 20px; }

/* ---------- POS 2-Column Workspace (Center Catalog + Right Cart) ---------- */
.pos-layout { display: flex; flex: 1; overflow: hidden; }
.pos-catalog { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; overflow: hidden; min-width: 0; }
.pos-toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.search-box {
  flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; height: 44px;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12); }
.search-box input { border: none; outline: none; background: transparent; width: 100%; font-size: 14px; }

.btn-action {
  height: 44px; padding: 0 14px; border-radius: 12px; display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13px; border: 1px solid var(--border); background: var(--surface);
  transition: all 0.15s ease; white-space: nowrap;
}
.btn-action:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-action.mic-btn { background: linear-gradient(135deg, #0D9488, #0284C7); color: #fff; border: none; }
.btn-action.mic-btn:hover { filter: brightness(1.06); color: #fff; }
.btn-action.mic-btn.listening { background: var(--danger); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
}

.category-pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; flex-shrink: 0; }
.cat-pill {
  padding: 7px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; color: var(--text-muted); white-space: nowrap;
}
.cat-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

.product-grid {
  flex: 1; overflow-y: auto; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; padding-bottom: 24px; align-content: start;
}
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease; position: relative;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #99F6E4; }
.product-thumb {
  height: 92px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 24px; color: #fff; position: relative; overflow: hidden;
}
.product-badge {
  position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; padding: 3px 7px;
  border-radius: 6px; background: #0F172A; color: #fff; text-transform: uppercase; letter-spacing: 0.03em;
}
.product-badge.cheap { background: #0284C7; }
.product-badge.low { background: var(--danger); }
.product-stock-tag {
  position: absolute; bottom: 6px; right: 6px; font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.92); color: var(--text);
}
.product-name { font-size: 13px; font-weight: 600; line-height: 1.3; min-height: 34px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-price { font-size: 14px; font-weight: 700; color: var(--primary); }
.product-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-muted); }

/* Right Cart Panel (Reference Image 1 Style) */
.cart-panel {
  width: var(--cart-w); background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.cart-header {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--border); gap: 6px;
}
.cart-top-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--text); background: var(--surface-alt);
}
.cart-top-btn:hover { background: var(--primary-soft); color: var(--primary); }
.cart-top-btn.danger { color: var(--danger); background: var(--danger-soft); }

.cart-customer-bar {
  padding: 8px 14px; background: var(--surface-alt); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; font-size: 12px;
}
.cart-items { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.cart-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--text-muted); gap: 8px; padding: 30px 16px;
}
.cart-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 13px; font-weight: 700; color: var(--primary); margin-top: 2px; }
.cart-item-unit { font-size: 11px; color: var(--text-muted); }
.qty-control { display: flex; align-items: center; gap: 8px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: 999px; border: 1.5px solid #CBD5E1;
  display: flex; align-items: center; justify-content: center; color: var(--text);
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.qty-val { min-width: 20px; text-align: center; font-weight: 700; font-size: 13px; }

.cart-footer { padding: 14px; border-top: 1px solid var(--border); background: var(--surface); }
.cart-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; }
.cart-row.total { font-size: 16px; font-weight: 800; margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border); }
.btn-primary {
  width: 100%; height: 46px; border-radius: 12px; background: var(--primary); color: #fff;
  font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  height: 40px; padding: 0 14px; border-radius: 10px; background: var(--surface-alt); border: 1px solid var(--border);
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger {
  height: 40px; padding: 0 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger);
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; border-radius: 8px; }

/* ---------- Cards, Tables, Forms ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.stat-sub { font-size: 12px; color: var(--text-muted); }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-alt); }
tr:hover td { background: #FAFCFD; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--primary-soft); color: var(--primary); }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.form-input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Modals & Toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100;
}
.modal-box {
  width: 100%; max-width: 480px; background: var(--surface); border-radius: 18px;
  box-shadow: var(--shadow-md); overflow: hidden; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.scanner-video-box {
  width: 100%; height: 220px; background: #0F172A; border-radius: 12px; overflow: hidden;
  position: relative; display: flex; align-items: center; justify-content: center; color: #94A3B8;
}
.scanner-video-box video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: absolute; width: 72%; height: 55%; border: 2px solid #2DD4BF; border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.45); pointer-events: none;
}

.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: #0F172A; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 8px; pointer-events: auto;
}
.toast.success { background: #065F46; }
.toast.error { background: #991B1B; }

/* Thermal Receipt Print View */
.receipt-preview {
  font-family: 'Courier New', monospace; font-size: 12px; background: #FFFDF7; color: #111;
  padding: 16px; border: 1px dashed #CBD5E1; border-radius: 10px; line-height: 1.5;
}
@media print {
  body * { visibility: hidden; }
  #printReceiptArea, #printReceiptArea * { visibility: visible; }
  #printReceiptArea { position: fixed; inset: 0; width: 58mm; margin: 0; padding: 4mm; border: none; }
}

/* Mobile Bottom Nav & Cart Floating Bar */
.mobile-cart-bar { display: none; }
.mobile-nav { display: none; }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .cart-panel {
    position: fixed; inset: 0; width: 100%; z-index: 60; transform: translateY(100%);
    transition: transform 0.25s ease;
  }
  .cart-panel.open { transform: translateY(0); }
  .mobile-cart-bar {
    display: flex; position: fixed; bottom: 64px; left: 12px; right: 12px; z-index: 40;
    background: var(--primary); color: #fff; border-radius: 14px; padding: 12px 16px;
    align-items: center; justify-content: space-between; box-shadow: var(--shadow-md); font-weight: 700;
  }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 60px; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--border); justify-content: space-around; align-items: center;
  }
  .mobile-nav .nav-btn { width: auto; flex: 1; padding: 6px 2px; border-radius: 0; }
  .pos-catalog { padding-bottom: 130px; }
  .view-scroll { padding-bottom: 84px; }
}
