/* ═══════════════════════════════════════════════════════════════
   Enterprise POS — Premium Dark/Light Theme
   Uses CSS custom properties for seamless mode switching
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Variables: Dark Mode (Default) ─────────────────────── */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-hover: #334155;
  --border: #334155;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.15);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.15);

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: all 0.2s ease;
}

/* ─── Light Mode Overrides ────────────────────────────────────── */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #1e293b;
  --bg-hover: #f8fafc;
  --border: #e2e8f0;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ─── Base Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── Layout Shell ───────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  overflow-y: auto;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed { width: 72px; }

.sidebar-brand {
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 12px 8px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.main-content.expanded { margin-left: 72px; }

/* ─── Top Header ─────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.header-toggle {
  width: 36px; height: 36px;
  border: none;
  background: var(--bg-hover);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.header-toggle:hover { background: var(--accent); color: white; }

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
  width: 36px; height: 36px;
  border: none;
  background: var(--bg-hover);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}
.theme-toggle:hover { background: var(--warning); color: white; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--bg-hover);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
}

/* ─── Page Content ───────────────────────────────────────────── */
.page-content { padding: 28px; flex: 1; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.pos-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.pos-card:hover { box-shadow: var(--shadow); }

/* ─── KPI Cards ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  cursor: default;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-icon.revenue { background: var(--success-soft); color: var(--success); }
.kpi-icon.profit  { background: var(--accent-soft);  color: var(--accent); }
.kpi-icon.orders  { background: var(--info-soft);    color: var(--info); }
.kpi-icon.expense { background: var(--danger-soft);  color: var(--danger); }
.kpi-icon.warning { background: var(--warning-soft); color: var(--warning); }

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn-pos {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  text-decoration: none;
}

.btn-pos:hover { transform: translateY(-1px); text-decoration: none; }

.btn-primary-pos { background: var(--accent); color: white; }
.btn-primary-pos:hover { background: var(--accent-hover); color: white; }

.btn-success-pos { background: var(--success); color: white; }
.btn-success-pos:hover { background: #059669; color: white; }

.btn-danger-pos  { background: var(--danger); color: white; }
.btn-danger-pos:hover { background: #dc2626; color: white; }

.btn-warning-pos { background: var(--warning); color: white; }
.btn-warning-pos:hover { background: #d97706; color: white; }

.btn-ghost { background: var(--bg-hover); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--border); color: var(--text-primary); }

/* ─── Tables ─────────────────────────────────────────────────── */
.pos-table { width: 100%; border-collapse: collapse; }
.pos-table thead th {
  background: var(--bg-hover);
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.pos-table tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
.pos-table tbody tr:last-child { border-bottom: none; }
.pos-table tbody tr:hover { background: var(--bg-hover); }
.pos-table tbody td { padding: 14px 16px; font-size: 14px; color: var(--text-primary); }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge-pos {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent); }

/* ─── Form Controls ──────────────────────────────────────────── */
.form-control-pos {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  width: 100%;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.form-control-pos:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-label-pos {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

/* ─── POS Screen Specifics ───────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - var(--header-height) - 100px);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 4px 2px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  user-select: none;
}

.product-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.product-card:active { transform: scale(0.97); }

.product-card.out-of-stock { opacity: 0.5; cursor: not-allowed; }

.product-card img {
  width: 60px; height: 60px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.product-card .product-emoji {
  width: 60px; height: 60px;
  background: var(--bg-hover);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 8px;
}

.product-card .product-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.product-card .product-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.product-card .stock-badge {
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── Cart Panel ─────────────────────────────────────────────── */
.cart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-items { flex: 1; overflow-y: auto; padding: 12px; }

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: var(--transition);
}
.cart-item:hover { background: var(--bg-hover); }

.cart-item-name { flex: 1; font-size: 13px; font-weight: 500; }
.cart-item-controls { display: flex; align-items: center; gap: 6px; }
.cart-qty-btn {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary);
  transition: var(--transition);
}
.cart-qty-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.cart-qty { font-size: 13px; font-weight: 600; min-width: 24px; text-align: center; }
.cart-item-price { font-size: 13px; font-weight: 600; color: var(--accent); min-width: 60px; text-align: right; }
.cart-item-remove { color: var(--danger); cursor: pointer; font-size: 14px; opacity: 0.7; }
.cart-item-remove:hover { opacity: 1; }

.cart-footer {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
}

.cart-totals .total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.cart-totals .total-row.grand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
}

/* ─── Category Filter Pills ──────────────────────────────────── */
.category-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.category-pill {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.category-pill:hover, .category-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ─── Toast Notifications ────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; }
.pos-toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-top: 8px;
  min-width: 280px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Loading Spinner ─────────────────────────────────────────── */
.pos-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Checkout Modal ─────────────────────────────────────────── */
.checkout-modal .modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.checkout-modal .modal-header {
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  color: white;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ─── Charts Container ───────────────────────────────────────── */
.chart-container { position: relative; height: 280px; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .cart-panel { height: 500px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Utility ─────────────────────────────────────────────────── */
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.gap-8  { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.rounded { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }

/* ─── Kitchen Display ─────────────────────────────────────────── */
.kitchen-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 20px;
  min-height: 100vh;
  background: #0a0a0a;
}

.kitchen-ticket {
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 12px;
  padding: 20px;
  color: #fff;
  animation: ticketAppear 0.4s ease;
}

.kitchen-ticket.urgent { border-color: #ef4444; }
.kitchen-ticket.ready  { border-color: #10b981; opacity: 0.6; }

@keyframes ticketAppear {
  from { opacity: 0; transform: scale(0.9) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.kitchen-ticket .order-number {
  font-size: 20px;
  font-weight: 800;
  color: #f59e0b;
  margin-bottom: 8px;
}

.kitchen-ticket .order-meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 14px;
}

.kitchen-ticket .order-item {
  font-size: 16px;
  font-weight: 600;
  padding: 6px 0;
  border-bottom: 1px solid #333;
}

.kitchen-ticket .item-qty {
  font-size: 20px;
  font-weight: 800;
  color: #f59e0b;
  margin-right: 10px;
}
