/* =========================================
   Restaurant Order System — Main Stylesheet
   Light/Dark mode via CSS variables
   ========================================= */

:root {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-sidebar: #1e293b;
  --bg-header: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-sidebar: #cbd5e1;
  --border: #e2e8f0;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --success: #22c55e;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-header: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-sidebar: #cbd5e1;
  --border: #334155;
  --primary-light: #312e81;
  --success-light: #14532d;
  --warning-light: #78350f;
  --danger-light: #7f1d1d;
  --info-light: #1e3a8a;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.4);
}

/* ─── Reset ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Utility ────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: .5rem; }
.gap-4 { gap: 1rem; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.p-4 { padding: 1rem; }
.w-full { width: 100%; }

/* ─── Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  user-select: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline   { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-sm        { padding: .35rem .8rem; font-size: .8rem; }
.btn-lg        { padding: .9rem 1.8rem; font-size: 1.1rem; }
.btn-icon      { padding: .5rem; border-radius: 50%; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ─── Form Elements ──────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .4rem;
}
.form-control {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: .95rem;
  transition: border var(--transition);
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-control::placeholder { color: var(--text-muted); }

/* ─── Cards ──────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 1.25rem; }

/* ─── Badges ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-pending  { background: var(--warning-light); color: var(--warning); }
.badge-preparing{ background: var(--info-light); color: var(--info); }
.badge-ready    { background: var(--success-light); color: var(--success); }
.badge-completed{ background: var(--border); color: var(--text-muted); }
.badge-cancelled{ background: var(--danger-light); color: var(--danger); }

/* ─── Toast Notifications ────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.25rem;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  max-width: 380px;
  animation: slideIn .25s ease;
  font-size: .9rem;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }
.toast.warning { border-left: 4px solid var(--warning); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ─── Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn .2s ease;
}
@keyframes scaleIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}

/* ─── Auth Pages ─────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1rem;
}
[data-theme="dark"] .auth-page {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
}
.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo h1 { font-size: 1.5rem; color: var(--primary); }
.auth-logo p  { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

/* ─── App Layout ─────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  width: 220px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { color: #fff; font-weight: 800; font-size: 1rem; }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  color: var(--text-sidebar);
  font-size: .9rem;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  margin: .15rem .5rem;
  border-radius: var(--radius-sm);
}
.nav-item:hover   { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active  { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,.08); }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.topbar-title { font-weight: 700; font-size: 1rem; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.page-content { flex: 1; overflow-y: auto; padding: 1.25rem; }

/* ─── POS Layout ─────────────────────────── */
.pos-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.pos-categories {
  width: 140px;
  background: var(--bg-sidebar);
  overflow-y: auto;
  flex-shrink: 0;
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.pos-cat-btn {
  width: 100%;
  padding: .8rem .5rem;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: opacity var(--transition), transform var(--transition);
  line-height: 1.3;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.pos-cat-btn:active { transform: scale(0.97); }
.pos-cat-btn.active { box-shadow: 0 0 0 3px #fff inset; }

.pos-products {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .65rem;
  align-content: start;
}
.product-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .5rem;
  touch-action: manipulation;
  user-select: none;
}
.product-card:hover  { border-color: var(--primary); box-shadow: var(--shadow-md); }
.product-card:active { transform: scale(0.95); }
.product-img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.product-img-placeholder {
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem;
}
.product-name { font-size: .82rem; font-weight: 600; line-height: 1.3; }
.product-price { font-size: .95rem; font-weight: 800; color: var(--primary); }

.pos-cart {
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.cart-header {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cart-items { flex: 1; overflow-y: auto; padding: .5rem; }
.cart-item {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .6rem .5rem;
  border-bottom: 1px solid var(--border);
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name  { font-size: .875rem; font-weight: 600; }
.cart-item-sups  { font-size: .75rem; color: var(--text-muted); }
.cart-item-price { font-size: .875rem; font-weight: 700; white-space: nowrap; }
.qty-control {
  display: flex;
  align-items: center;
  gap: .25rem;
}
.qty-btn {
  width: 26px; height: 26px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  font-size: 1rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
}
.qty-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.qty-val { font-size: .9rem; font-weight: 700; min-width: 20px; text-align: center; }
.cart-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.cart-totals { margin-bottom: 1rem; }
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: .875rem;
  padding: .15rem 0;
}
.total-row.final { font-size: 1.1rem; font-weight: 800; border-top: 1.5px solid var(--border); padding-top: .5rem; margin-top: .35rem; }
.cart-meta { display: flex; gap: .5rem; margin-bottom: .75rem; }
.cart-meta .form-control { font-size: .8rem; padding: .45rem .65rem; }

/* ─── Kitchen Layout ─────────────────────── */
.kitchen-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #0f172a;
  color: #f1f5f9;
}
.kitchen-header {
  background: #1e293b;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #334155;
}
.kitchen-title { font-size: 1.5rem; font-weight: 900; color: #fff; }
.kitchen-orders {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  align-content: start;
}
.kitchen-card {
  background: #1e293b;
  border-radius: var(--radius-lg);
  border: 2px solid #334155;
  overflow: hidden;
  transition: border-color var(--transition);
}
.kitchen-card.pending   { border-color: var(--warning); }
.kitchen-card.preparing { border-color: var(--info); }
.kitchen-card.ready     { border-color: var(--success); }
.kitchen-card-header {
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kitchen-card.pending .kitchen-card-header   { background: rgba(245,158,11,.15); }
.kitchen-card.preparing .kitchen-card-header { background: rgba(59,130,246,.15); }
.kitchen-card.ready .kitchen-card-header     { background: rgba(34,197,94,.15); }
.kitchen-order-num { font-size: 1.2rem; font-weight: 900; color: #fff; }
.kitchen-time { font-size: .8rem; color: #94a3b8; }
.kitchen-card-body { padding: 1rem; }
.kitchen-item {
  padding: .5rem 0;
  border-bottom: 1px solid #334155;
}
.kitchen-item:last-child { border-bottom: none; }
.kitchen-item-name { font-size: 1rem; font-weight: 700; color: #f1f5f9; }
.kitchen-item-qty  { font-size: 1.25rem; font-weight: 900; color: var(--primary); }
.kitchen-sups { font-size: .85rem; color: #94a3b8; margin-top: .2rem; }
.kitchen-note { font-size: .85rem; color: var(--warning); margin-top: .5rem; font-style: italic; }
.kitchen-card-footer {
  padding: .75rem 1rem;
  display: flex;
  gap: .5rem;
  border-top: 1px solid #334155;
}
.kitchen-elapsed {
  font-size: .8rem;
  color: #94a3b8;
  padding: .5rem 1rem;
}
.kitchen-elapsed.urgent { color: var(--danger); font-weight: 700; }

/* ─── Empty state ────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  text-align: center;
  gap: 1rem;
}
.empty-state .icon { font-size: 3rem; }

/* ─── Table ──────────────────────────────── */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); text-align: left; }
th { font-weight: 700; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ─── Tab System ─────────────────────────── */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: .65rem 1rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Toggle (Theme/Lang) ────────────────── */
.toggle-group { display: flex; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.toggle-opt {
  padding: .35rem .8rem;
  border: none;
  background: none;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.toggle-opt.active { background: var(--primary); color: #fff; }

/* ─── Notification Banner ────────────────── */
.notif-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: var(--success);
  color: #fff;
  padding: 1rem 2rem;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  animation: bounceIn .3s ease;
  display: flex;
  align-items: center;
  gap: .75rem;
}
@keyframes bounceIn {
  from { transform: translateX(-50%) scale(.8); opacity: 0; }
  to   { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ─── Print ──────────────────────────────── */
@media print {
  .no-print { display: none !important; }
  .receipt { width: 80mm; margin: 0 auto; font-family: monospace; font-size: 11px; }
  .receipt-title { font-size: 14px; font-weight: bold; text-align: center; }
  .receipt-divider { border-top: 1px dashed #000; margin: 6px 0; }
  .receipt-row { display: flex; justify-content: space-between; }
  .receipt-disclaimer { font-size: 9px; text-align: center; color: #666; margin-top: 10px; }
}

/* ─── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* ─── Responsive ─────────────────────────── */
@media (max-width: 768px) {
  .pos-categories { width: 80px; }
  .pos-cat-btn { font-size: .7rem; padding: .65rem .3rem; }
  .pos-cart { width: 260px; }
  .pos-products { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .product-img, .product-img-placeholder { width: 56px; height: 56px; }
  .kitchen-orders { grid-template-columns: 1fr; }
  .sidebar { width: 180px; }
}
