/* ============================================================
   PETROMART CAMBODIA — Design System
   Dual-theme: Dark POS (default) + Sunlight Forecourt (mobile)
   Font: Inter (Latin) + Noto Sans Khmer
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Khmer:wght@300;400;500;600;700&display=swap');

/* ── ROOT TOKENS ─────────────────────────────────────────── */
:root {
  /* Colors — Dark POS palette */
  --bg-base:       #0f1117;
  --bg-surface:    #1a1d26;
  --bg-elevated:   #22263a;
  --bg-card:       #1e2235;

  --accent-green:  #22c55e;
  --accent-blue:   #3b82f6;
  --accent-amber:  #f59e0b;
  --accent-red:    #ef4444;
  --accent-purple: #8b5cf6;
  --accent-khr:    #f97316; /* KHR orange */

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #0f1117;

  --border-subtle:  rgba(255,255,255,0.08);
  --border-normal:  rgba(255,255,255,0.15);
  --border-strong:  rgba(255,255,255,0.25);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow-green: 0 0 20px rgba(34,197,94,0.3);
  --shadow-glow-red:   0 0 20px rgba(239,68,68,0.3);

  /* Typography */
  --font-latin:  'Inter', system-ui, sans-serif;
  --font-khmer:  'Noto Sans Khmer', 'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Courier New', monospace;

  /* Sizing */
  --touch-min:  56px;   /* Minimum touch target */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Transitions */
  --t-fast:   100ms ease;
  --t-normal: 200ms ease;
  --t-slow:   350ms ease;

  /* Z-index scale */
  --z-modal:   1000;
  --z-overlay: 900;
  --z-drawer:  800;
  --z-toast:   1100;
}

/* ── FORECOURT THEME (light, sunlight-readable) ─────────── */
[data-theme="forecourt"] {
  --bg-base:       #f0f4f8;
  --bg-surface:    #ffffff;
  --bg-elevated:   #e2e8f0;
  --bg-card:       #ffffff;

  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;

  --border-subtle:  rgba(0,0,0,0.08);
  --border-normal:  rgba(0,0,0,0.15);
  --border-strong:  rgba(0,0,0,0.30);

  --touch-min: 64px; /* Even larger for outdoor use */
}

/* ── CSS RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-latin);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ── TYPOGRAPHY ─────────────────────────────────────────── */
.khmer  { font-family: var(--font-khmer); }
.mono   { font-family: var(--font-mono); }

.text-xs   { font-size: 0.75rem; }
.text-sm   { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg   { font-size: 1.125rem; }
.text-xl   { font-size: 1.25rem; }
.text-2xl  { font-size: 1.5rem; }
.text-3xl  { font-size: 1.875rem; }
.text-4xl  { font-size: 2.25rem; }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-green     { color: var(--accent-green); }
.text-red       { color: var(--accent-red); }
.text-amber     { color: var(--accent-amber); }
.text-blue      { color: var(--accent-blue); }
.text-khr       { color: var(--accent-khr); }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

/* ── LAYOUT UTILITIES ───────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-1       { flex: 1; }
.gap-1        { gap: 0.25rem; }
.gap-2        { gap: 0.5rem; }
.gap-3        { gap: 0.75rem; }
.gap-4        { gap: 1rem; }
.gap-6        { gap: 1.5rem; }
.gap-8        { gap: 2rem; }

.grid         { display: grid; }
.grid-2       { grid-template-columns: repeat(2, 1fr); }
.grid-3       { grid-template-columns: repeat(3, 1fr); }
.grid-4       { grid-template-columns: repeat(4, 1fr); }
.grid-6       { grid-template-columns: repeat(6, 1fr); }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.h-screen { height: 100dvh; }

.p-1  { padding: 0.25rem; }
.p-2  { padding: 0.5rem; }
.p-3  { padding: 0.75rem; }
.p-4  { padding: 1rem; }
.p-6  { padding: 1.5rem; }
.p-8  { padding: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

.m-auto { margin: auto; }
.mt-2  { margin-top: 0.5rem; }
.mt-4  { margin-top: 1rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-2  { margin-bottom: 0.5rem; }

.overflow-hidden  { overflow: hidden; }
.overflow-y-auto  { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.inset-0  { top:0; right:0; bottom:0; left:0; }
.z-modal  { z-index: var(--z-modal); }
.z-toast  { z-index: var(--z-toast); }

/* ── SURFACE CARDS ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--touch-min);
  padding: 0 1.5rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  transition: all var(--t-normal);
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-green);
  color: var(--text-inverse);
  box-shadow: var(--shadow-glow-green);
}
.btn-primary:hover { background: #16a34a; }

.btn-danger {
  background: var(--accent-red);
  color: #fff;
  box-shadow: var(--shadow-glow-red);
}
.btn-danger:hover { background: #dc2626; }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-normal);
}
.btn-secondary:hover { background: var(--bg-card); border-color: var(--border-strong); }

.btn-amber {
  background: var(--accent-amber);
  color: #1a1a1a;
}
.btn-amber:hover { background: #d97706; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover { border-color: var(--border-normal); color: var(--text-primary); }

.btn-lg  { min-height: 64px; font-size: 1.125rem; padding: 0 2rem; }
.btn-sm  { min-height: 40px; font-size: 0.875rem; padding: 0 1rem; }
.btn-xl  { min-height: 80px; font-size: 1.25rem; padding: 0 2.5rem; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── FORM INPUTS ─────────────────────────────────────────── */
.input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.875rem 1rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1.5px solid var(--border-normal);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: border-color var(--t-fast);
  outline: none;
}
.input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.input::placeholder { color: var(--text-muted); }
.input-lg { min-height: 64px; font-size: 1.25rem; }

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── BADGE / PILL ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}
.badge-green  { background: rgba(34,197,94,0.15);  color: var(--accent-green); }
.badge-red    { background: rgba(239,68,68,0.15);   color: var(--accent-red); }
.badge-amber  { background: rgba(245,158,11,0.15);  color: var(--accent-amber); }
.badge-blue   { background: rgba(59,130,246,0.15);  color: var(--accent-blue); }
.badge-purple { background: rgba(139,92,246,0.15);  color: var(--accent-purple); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--t-normal);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.25rem; font-weight: 700; }
.modal-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background var(--t-fast);
}
.modal-close:hover { background: var(--bg-card); color: var(--text-primary); }

/* ── TOAST NOTIFICATIONS ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  font-size: 0.9rem;
  animation: slideInRight 200ms ease forwards;
  pointer-events: all;
  min-width: 260px;
  max-width: 380px;
}
.toast.toast-success { border-left: 4px solid var(--accent-green); }
.toast.toast-error   { border-left: 4px solid var(--accent-red); }
.toast.toast-warn    { border-left: 4px solid var(--accent-amber); }
.toast.toast-info    { border-left: 4px solid var(--accent-blue); }
@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── POS-SPECIFIC COMPONENTS ─────────────────────────────── */
/* Currency display */
.currency-usd {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.currency-khr {
  font-family: var(--font-khmer);
  color: var(--accent-khr);
  font-weight: 600;
}
/* Large total display */
.total-display {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  text-align: right;
}
.total-display .amount-usd {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-green);
  font-variant-numeric: tabular-nums;
}
.total-display .amount-khr {
  font-size: 1rem;
  color: var(--accent-khr);
  font-family: var(--font-khmer);
  margin-top: 0.25rem;
}

/* Cart item row */
.cart-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name { flex: 1; font-size: 0.9rem; }
.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.qty-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-normal);
  color: var(--text-primary);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--t-fast);
}
.qty-btn:hover { background: var(--bg-card); }
.qty-value { min-width: 28px; text-align: center; font-weight: 600; }
.cart-item-price { font-weight: 700; min-width: 60px; text-align: right; }
.cart-item-vat { font-size: 0.7rem; color: var(--text-muted); }

/* Hotkey grid */
.hotkey-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.hotkey-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  min-height: var(--touch-min);
  text-align: left;
}
.hotkey-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent-green);
  box-shadow: 0 0 0 2px rgba(34,197,94,0.15);
}
.hotkey-btn:active { transform: scale(0.97); }
.hotkey-name { font-size: 0.8rem; font-weight: 600; line-height: 1.2; color: var(--text-primary); }
.hotkey-price-usd { font-size: 0.85rem; font-weight: 700; color: var(--accent-green); }
.hotkey-price-khr { font-size: 0.7rem; color: var(--accent-khr); font-family: var(--font-khmer); }

/* PIN pad */
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 280px;
  margin: 0 auto;
}
.pin-key {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-normal);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  user-select: none;
}
.pin-key:hover { background: var(--bg-card); border-color: var(--accent-blue); }
.pin-key:active { transform: scale(0.93); background: var(--accent-blue); color: #fff; }
.pin-key.pin-delete { color: var(--accent-red); }
.pin-key.pin-enter { background: var(--accent-green); color: var(--text-inverse); border-color: transparent; }

/* PIN dots display */
.pin-dots {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin: 1rem 0;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: background var(--t-fast);
}
.pin-dot.filled { background: var(--accent-green); border-color: var(--accent-green); }

/* Drawer lock overlay */
.drawer-lock-overlay {
  position: fixed; inset: 0;
  background: rgba(239,68,68,0.95);
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: #fff;
  animation: pulseRed 2s ease-in-out infinite;
}
@keyframes pulseRed {
  0%, 100% { background: rgba(239,68,68,0.95); }
  50%       { background: rgba(185,28,28,0.98); }
}
.drawer-lock-icon { font-size: 5rem; }
.drawer-lock-title { font-size: 2rem; font-weight: 800; }
.drawer-lock-msg { font-size: 1.1rem; opacity: 0.9; text-align: center; max-width: 320px; }

/* Status indicator */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
}
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  animation: syncPulse 2s ease-in-out infinite;
}
.sync-dot.online  { background: var(--accent-green); }
.sync-dot.offline { background: var(--accent-red); animation: none; }
.sync-dot.syncing { background: var(--accent-amber); }
@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── KDS COMPONENTS ──────────────────────────────────────── */
.kds-order-card {
  background: var(--bg-card);
  border: 2px solid var(--border-normal);
  border-radius: var(--radius-lg);
  padding: 1rem;
  transition: border-color var(--t-normal);
}
.kds-order-card.age-fresh   { border-color: var(--accent-green); }
.kds-order-card.age-warning { border-color: var(--accent-amber); }
.kds-order-card.age-urgent  { border-color: var(--accent-red); animation: urgentPulse 1s ease-in-out infinite; }
@keyframes urgentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0.3); }
}

/* ── TANK GAUGE ──────────────────────────────────────────── */
.tank-gauge {
  position: relative;
  height: 120px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-normal);
  overflow: hidden;
}
.tank-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  transition: height 1s ease;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.tank-fill.critical {
  background: linear-gradient(180deg, #f97316 0%, #ea580c 100%);
  animation: criticalPulse 2s ease-in-out infinite;
}
@keyframes criticalPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}
.tank-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ── SCROLLBARS ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-normal); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .hotkey-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4      { grid-template-columns: repeat(2, 1fr); }
  .grid-6      { grid-template-columns: repeat(3, 1fr); }
  .modal       { padding: 1.5rem; }
  body         { font-size: 15px; }
}
@media (max-width: 480px) {
  .hotkey-grid { grid-template-columns: repeat(2, 1fr); }
  .btn-xl      { min-height: 64px; }
  .modal       { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ── PRINT STYLES ────────────────────────────────────────── */
@media print {
  * { background: white !important; color: black !important; }
  .no-print { display: none !important; }
}
