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

/* ======================================================
   DESIGN TOKENS
   ====================================================== */
:root {
  --primary:        #4f46e5;
  --primary-hover:  #4338ca;
  --primary-light:  rgba(79, 70, 229, 0.08);
  --accent:         #ec4899;
  --bg-color:       #f1f5f9;
  --bg-subtle:      #e2e8f0;
  --card-bg:        #ffffff;
  /* Sidebar — light mode uses a white panel with border */
  --sidebar-bg:     #ffffff;
  --sidebar-text:   #64748b;
  --sidebar-active: #ffffff;
  --sidebar-border: #e2e8f0;
  --text-main:      #0f172a;
  --text-muted:     #64748b;
  --border-color:   #e2e8f0;
  --danger:         #ef4444;
  --danger-light:   rgba(239, 68, 68, 0.1);
  --success:        #10b981;
  --success-light:  rgba(16, 185, 129, 0.1);
  --warning:        #f59e0b;
  --warning-light:  rgba(245, 158, 11, 0.1);
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl:      0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --radius-xl:      20px;
}

[data-theme="dark"] {
  --primary:        #6366f1;
  --primary-hover:  #4f46e5;
  --primary-light:  rgba(99, 102, 241, 0.12);
  --bg-color:       #0f172a;
  --bg-subtle:      #1e293b;
  --card-bg:        #1e293b;
  --sidebar-bg:     #020617;
  --sidebar-border: #1e293b;
  --sidebar-text:   #64748b;
  --sidebar-active: #ffffff;
  --text-main:      #f1f5f9;
  --text-muted:     #94a3b8;
  --border-color:   #334155;
  --danger-light:   rgba(239, 68, 68, 0.15);
  --success-light:  rgba(16, 185, 129, 0.15);
  --warning-light:  rgba(245, 158, 11, 0.15);
}

/* ======================================================
   RESET & BASE
   ====================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  transition: background 0.3s, color 0.3s;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 16px;
}

/* ======================================================
   APP LAYOUT
   ====================================================== */
.app-container {
  display: grid;
  grid-template-columns: 220px 1fr 340px;
  height: 100vh;
}

/* ======================================================
   SIDEBAR NAVIGATION
   ====================================================== */
.nav-sidebar {
  background: var(--sidebar-bg);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
  transition: background 0.3s, border-color 0.3s;
}

.nav-sidebar h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 32px;
  padding: 0 12px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-item {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

[data-theme="dark"] .nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-active);
}

.nav-item.active {
  background: var(--primary);
  color: var(--sidebar-active);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

/* ======================================================
   MAIN CONTENT
   ====================================================== */
.main-content {
  padding: 28px;
  overflow-y: auto;
  background: var(--bg-color);
}

/* ======================================================
   TOP BAR (POS)
   ====================================================== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* ======================================================
   CATEGORY FILTERS
   ====================================================== */
.category-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
}

.category-btn {
  padding: 6px 16px;
  border-radius: 50px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s ease;
  font-family: inherit;
}

.category-btn.active, .category-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

/* ======================================================
   PRODUCT GRID
   ====================================================== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.product-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  opacity: 0;
  transition: opacity 0.18s ease;
  border-radius: var(--radius-lg);
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.product-card:hover::before { opacity: 0.04; }
.product-card:active { transform: scale(0.97); }

.product-img-wrap {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-img-placeholder {
  font-size: 24px;
  color: var(--text-muted);
}

.product-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.3;
}

.product-price {
  color: var(--primary);
  font-weight: 700;
  font-size: 1rem;
}

.product-stock {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 50px;
}

.stock-low {
  color: var(--danger) !important;
  background: var(--danger-light) !important;
  font-weight: 600;
}

/* ======================================================
   CART SIDEBAR
   ====================================================== */
.cart-sidebar {
  background: var(--card-bg);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  box-shadow: -4px 0 24px rgba(0,0,0,0.04);
}

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

.cart-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-color);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: border-color 0.15s;
}

.cart-item:hover { border-color: var(--primary); }

.cart-item-info { display: flex; flex-direction: column; gap: 2px; }

.cart-item-title { font-weight: 600; font-size: 0.85rem; }

.cart-item-price { font-size: 0.8rem; color: var(--text-muted); }

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}

.qty-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.15s;
}

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

.cart-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px dashed var(--border-color);
}

/* Payment tabs */
.pay-tab {
  flex: 1;
  padding: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.pay-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Buttons */
.checkout-btn {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
  letter-spacing: 0.02em;
}

.checkout-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

.hold-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.15s;
  font-family: inherit;
}

.hold-btn:hover { background: var(--primary-light); border-color: var(--primary); }

/* ======================================================
   FORMS & INPUTS
   ====================================================== */
input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-main);
  margin-bottom: 10px;
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

input::placeholder { color: var(--text-muted); }
.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.form-btn {
  background: var(--primary);
  color: white;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  font-family: inherit;
  transition: all 0.15s;
}

.form-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ======================================================
   DASHBOARD KPI CARDS
   ====================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.blue::after   { background: linear-gradient(90deg, #4f46e5, #7c3aed); }
.kpi-card.green::after  { background: linear-gradient(90deg, #10b981, #059669); }
.kpi-card.orange::after { background: linear-gradient(90deg, #f59e0b, #d97706); }
.kpi-card.pink::after   { background: linear-gradient(90deg, #ec4899, #db2777); }

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

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.kpi-icon.blue   { background: rgba(79, 70, 229, 0.12); }
.kpi-icon.green  { background: var(--success-light); }
.kpi-icon.orange { background: var(--warning-light); }
.kpi-icon.pink   { background: rgba(236, 72, 153, 0.12); }

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ======================================================
   DASHBOARD SECTIONS
   ====================================================== */
.dashboard-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* ======================================================
   TABLES
   ====================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead tr {
  border-bottom: 2px solid var(--border-color);
}

th {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

tbody tr:hover { background: var(--bg-subtle); }
tbody tr:last-child td { border-bottom: none; }

/* ======================================================
   BADGE & STATUS CHIPS
   ====================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

.rank-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ======================================================
   STAT CARDS (Reports)
   ====================================================== */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* ======================================================
   MODAL
   ====================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--card-bg);
  padding: 28px;
  border-radius: var(--radius-xl);
  width: 420px;
  max-width: 92vw;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ======================================================
   LOGIN SCREEN
   ====================================================== */
#login-screen {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
}

.login-card {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 48px 40px;
  border-radius: var(--radius-xl);
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 32px 64px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  animation: slideUp 0.3s ease;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: -80px; left: -80px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(99,102,241,0.3) 0%, transparent 70%);
  pointer-events: none;
}

.login-card::after {
  content: '';
  position: absolute;
  bottom: -60px; right: -60px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(236,72,153,0.25) 0%, transparent 70%);
  pointer-events: none;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-mark {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 4px;
  letter-spacing: -0.04em;
}

.login-logo p {
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.login-field input {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.95rem;
  margin: 0;
  transition: all 0.2s;
}

.login-field input::placeholder { color: rgba(255,255,255,0.3); }

.login-field input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
  background: rgba(255,255,255,0.12);
}

.login-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  letter-spacing: 0.02em;
  font-family: inherit;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.5);
}

.login-btn:active { transform: scale(0.99); }

.login-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 24px 0;
}

.login-footer {
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.3);
}

/* ======================================================
   ALERTS / EMPTY STATES
   ====================================================== */
.muted { color: var(--text-muted); font-size: 0.875rem; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ======================================================
   ALERT ROW (low stock)
   ====================================================== */
.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--danger-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.alert-row .alert-name { font-weight: 600; color: var(--text-main); }
.alert-row .alert-qty  { font-weight: 700; color: var(--danger); }

/* ======================================================
   HIDDEN
   ====================================================== */
.hidden { display: none !important; }

/* ======================================================
   RECEIPT PRINT
   ====================================================== */
@media print {
  body * { visibility: hidden; }
  #receipt-modal, #receipt-modal * { visibility: visible; }
  #receipt-modal {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    margin: 0; padding: 0;
    box-shadow: none;
  }
  .no-print { display: none !important; }
}
