/* ── POS System Styles ─────────────────────────────────── */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #475569;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --dark: #0f172a;
  --light: #f8fafc;
  --gray-50: #f9fafb;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --sidebar-width: 250px;
  --sidebar-collapsed: 60px;
  --topbar-height: 60px;
  --font-body: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--gray-100);
  color: var(--dark);
  margin: 0;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--dark);
  color: #fff;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  gap: 10px;
}
.sidebar-brand i { color: var(--primary); font-size: 1.4rem; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-nav .nav-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gray-400);
  padding: 16px 20px 6px;
  font-weight: 600;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.sidebar-nav a.active {
  background: rgba(37,99,235,0.15);
  color: #fff;
  border-left-color: var(--primary);
}
.sidebar-nav a i { width: 20px; text-align: center; font-size: 1rem; }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1030;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar h1 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--dark);
}

.btn-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--secondary);
  padding: 4px;
}

/* ── Main Content ─────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-height));
}

/* ── Cards ────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
}
.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}
.card-body { padding: 24px; }

/* ── Tables ───────────────────────────────────────────── */
.table {
  font-size: 0.875rem;
}
.table thead th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.8px;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  padding: 10px 12px;
  white-space: nowrap;
}
.table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--gray-100);
}
.table tbody tr:hover { background: var(--gray-50); }

/* ── Forms ────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--radius);
  border: 1px solid var(--gray-300);
  font-size: 0.875rem;
  padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.form-label {
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--secondary);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn { border-radius: var(--radius); font-size: 0.85rem; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ── POS Screen ───────────────────────────────────────── */
.pos-container {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  height: calc(100vh - var(--topbar-height) - 48px);
}

.pos-search {
  position: relative;
}
.pos-search .form-control {
  padding-left: 40px;
  height: 48px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}
.pos-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}
.pos-search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}
.pos-search-results.show { display: block; }

.pos-search-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
}
.pos-search-item:hover { background: var(--primary-light); }
.pos-search-item .item-name { font-weight: 500; }
.pos-search-item .item-meta { font-size: 0.78rem; color: var(--gray-500); }
.pos-search-item .item-price { font-weight: 600; color: var(--primary); }

.cart-panel {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

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

.cart-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cart-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.cart-item-name { font-weight: 500; font-size: 0.9rem; }
.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cart-item-controls button {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--gray-300);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.1s;
}
.cart-item-controls button:hover { background: var(--gray-100); }
.cart-item-controls .qty { font-weight: 600; min-width: 24px; text-align: center; }
.cart-item-remove {
  background: none !important;
  border: none !important;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
}

.cart-summary {
  padding: 16px 20px;
  border-top: 2px solid var(--gray-200);
  background: var(--gray-50);
}
.cart-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.875rem;
}
.cart-summary-row.total {
  font-size: 1.15rem;
  font-weight: 700;
  border-top: 1px solid var(--gray-300);
  padding-top: 8px;
  margin-top: 4px;
}

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

/* ── Badges ───────────────────────────────────────────── */
.badge-stock-low {
  background: #fef2f2;
  color: var(--danger);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-stock-ok {
  background: #f0fdf4;
  color: var(--success);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Receipt ──────────────────────────────────────────── */
.receipt {
  max-width: 380px;
  margin: 0 auto;
  background: #fff;
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.receipt-header { text-align: center; margin-bottom: 16px; border-bottom: 1px dashed #999; padding-bottom: 12px; }
.receipt-header h2 { margin: 0 0 4px; font-size: 1.1rem; }
.receipt-table { width: 100%; border-collapse: collapse; }
.receipt-table th, .receipt-table td { padding: 3px 0; text-align: left; }
.receipt-table .text-right { text-align: right; }
.receipt-divider { border-top: 1px dashed #999; margin: 8px 0; }
.receipt-footer { text-align: center; margin-top: 16px; border-top: 1px dashed #999; padding-top: 12px; font-size: 0.75rem; color: #666; }

/* ── Login ────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 40px;
}
.login-card h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 8px;
  color: var(--dark);
}
.login-card .subtitle {
  text-align: center;
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ── Responsive ───────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .btn-sidebar-toggle { display: block; }
  .pos-container { grid-template-columns: 1fr; height: auto; }
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .receipt { box-shadow: none; max-width: 100%; }
}
