/* ============================================================
   CHOUKRI ERP — MAIN STYLESHEET
   Design: Premium Dark/Light Mode with French Business UI
   ============================================================ */

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

/* ============================================================
   CSS CUSTOM PROPERTIES (TOKENS)
   ============================================================ */
:root {
  /* Brand */
  --brand-primary: #2563eb;
  --brand-primary-dark: #1d4ed8;
  --brand-primary-light: #3b82f6;
  --brand-secondary: #0ea5e9;
  --brand-accent: #f59e0b;

  /* Light Mode */
  --bg-body: #f0f4f8;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-sidebar: #1e293b;
  --bg-sidebar-hover: #334155;
  --bg-topbar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-table-header: #f1f5f9;
  --bg-table-row-alt: #f8fafc;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;
  --text-on-brand: #ffffff;

  --border-color: #e2e8f0;
  --border-color-2: #cbd5e1;
  --border-focus: #2563eb;

  --shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.05), 0 1px 4px -1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 8px 16px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 32px -8px rgba(15, 23, 42, 0.1), 0 8px 16px -4px rgba(15, 23, 42, 0.05);

  /* Status Colors */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #0284c7;
  --info-bg: #e0f2fe;
  --secondary: #64748b;
  --secondary-bg: #f1f5f9;

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.35s ease;
}

/* Dark Mode Tokens */
body.dark-mode {
  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-2: #162032;
  --bg-sidebar: #0d1829;
  --bg-sidebar-hover: #1e293b;
  --bg-topbar: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --bg-table-header: #162032;
  --bg-table-row-alt: #172135;

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

  --border-color: #1e293b;
  --border-color-2: #334155;
  --border-focus: #3b82f6;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 20px rgba(0,0,0,.5);
}

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

html { font-size: 14px; scroll-behavior: smooth; }

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

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-dark); }

img { max-width: 100%; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; transition: var(--transition); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* Global Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
body.dark-mode ::-webkit-scrollbar-track { background: var(--bg-body); }
body.dark-mode ::-webkit-scrollbar-thumb { background: #334155; }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: #475569; }

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

.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  line-height: 1.2;
}
.sidebar-brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  letter-spacing: -.3px;
}
.sidebar-brand-sub {
  font-size: .7rem;
  color: #64748b;
  font-weight: 400;
}

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

.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 16px 20px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-sidebar);
  font-size: .85rem;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: white;
}

.nav-link.active {
  background: rgba(37,99,235,.2);
  color: white;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--brand-primary);
  border-radius: 0 3px 3px 0;
}

.nav-link .nav-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: .8;
}

.nav-link.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

/* Sub-nav */
.nav-submenu {
  display: none;
  background: rgba(0,0,0,.15);
}
.nav-submenu .nav-link {
  padding-left: 48px;
  font-size: .8rem;
  font-weight: 400;
}

.nav-link.has-submenu::after {
  content: '›';
  margin-left: auto;
  font-size: 1.1rem;
  transition: transform .2s;
}
.nav-link.has-submenu.open::after { transform: rotate(90deg); }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 12px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.user-card:hover { background: var(--bg-sidebar-hover); }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: .8rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: .7rem;
  color: #64748b;
}

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 999;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; }

.menu-toggle {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: none;
}
.menu-toggle:hover { background: var(--bg-surface-2); }

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: .85rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.topbar-search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
}

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

.topbar-btn {
  width: 36px; height: 36px;
  border: none;
  background: var(--bg-surface-2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  font-size: 1rem;
}
.topbar-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.notif-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-topbar);
}

/* PAGE CONTENT */
.page-content {
  flex: 1;
  padding: 24px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: rgba(255, 255, 255, 0.85); /* Glassmorphism base */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg); /* Slightly rounder corners */
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition-slow);
}
.card:hover {
  box-shadow: var(--shadow-md);
}

body.dark-mode .card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-2);
}

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

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

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--kpi-color, var(--brand-primary)), transparent);
}

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

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

.kpi-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  background: rgba(37,99,235,.1);
  color: var(--brand-primary);
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-value sup {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-change {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  font-weight: 500;
}
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead th {
  background: var(--bg-table-header);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--text-primary); }

thead th.sorted-asc::after  { content: ' ↑'; }
thead th.sorted-desc::after { content: ' ↓'; }

tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }
body.dark-mode tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }

tbody tr:hover { 
  background: rgba(37,99,235,.04); 
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.05);
  position: relative;
  z-index: 10;
}

tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.table-actions { display: flex; gap: 6px; align-items: center; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .875rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

textarea.form-control { min-height: 90px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.form-row-2 { grid-template-columns: repeat(2, 1fr); }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }
.form-row-4 { grid-template-columns: repeat(4, 1fr); }

.input-group {
  position: relative;
  display: flex;
  align-items: stretch;
}
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group-text {
  padding: 9px 12px;
  background: var(--bg-table-header);
  border: 1.5px solid var(--border-color);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-size: .875rem;
  white-space: nowrap;
}

.form-help {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}
.form-check label {
  margin: 0;
  cursor: pointer;
  font-weight: 400;
  color: var(--text-primary);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: .85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: white;
  box-shadow: 0 4px 10px rgba(37,99,235,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary));
  color: white;
  box-shadow: 0 6px 14px rgba(37,99,235,0.4);
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-secondary:hover:not(:disabled) { background: var(--border-color); color: var(--text-primary); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) { background: #15803d; color: white; }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; color: white; }

.btn-warning {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}
.btn-warning:hover:not(:disabled) { background: #b45309; color: white; }

.btn-info {
  background: var(--info);
  color: white;
  border-color: var(--info);
}
.btn-info:hover:not(:disabled) { background: #0369a1; color: white; }

.btn-outline-primary {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline-primary:hover:not(:disabled) {
  background: var(--brand-primary);
  color: white;
}

.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-lg { padding: 11px 24px; font-size: .95rem; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-primary   { background: rgba(37,99,235,.12); color: #2563eb; }
.badge-success   { background: var(--success-bg); color: var(--success); }
.badge-danger    { background: var(--danger-bg); color: var(--danger); }
.badge-warning   { background: var(--warning-bg); color: var(--warning); }
.badge-info      { background: var(--info-bg); color: var(--info); }
.badge-secondary { background: var(--secondary-bg); color: var(--secondary); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .875rem;
}
.alert-success { background: var(--success-bg); border-color: var(--success); color: #166534; }
.alert-danger   { background: var(--danger-bg);  border-color: var(--danger);  color: #991b1b; }
.alert-warning  { background: var(--warning-bg); border-color: var(--warning); color: #92400e; }
.alert-info     { background: var(--info-bg);    border-color: var(--info);    color: #075985; }

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  opacity: .6;
  font-size: 1rem;
  color: inherit;
  padding: 0;
}
.alert-close:hover { opacity: 1; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 9998;
  animation: fadeIn .2s ease;
}
.modal-overlay.open { display: flex; align-items: center; justify-content: center; padding: 20px; }

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .25s ease;
}
.modal.modal-lg { max-width: 900px; }
.modal.modal-xl { max-width: 1200px; }
.modal.modal-sm { max-width: 400px; }

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

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   PRICE COMPARISON WIDGET
   ============================================================ */
.price-compare {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
  font-size: .8rem;
}

.price-compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}
.price-compare-label { color: var(--text-muted); }
.price-compare-value { font-weight: 600; }
.price-up   { color: var(--danger); }
.price-down { color: var(--success); }
.price-same { color: var(--text-secondary); }

.cost-alert {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 8px;
  font-size: .8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cost-alert-red    { background: var(--danger-bg); color: var(--danger); }
.cost-alert-green  { background: var(--success-bg); color: var(--success); }
.cost-alert-yellow { background: var(--warning-bg); color: var(--warning); }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 20px;
  gap: 0;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-primary); }
.breadcrumb-sep { color: var(--border-color-2); }

.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  list-style: none;
  gap: 4px;
  flex-wrap: wrap;
}
.pagination li a,
.pagination li span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  padding: 0 8px;
}
.pagination li a:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.pagination li.active a {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}

/* ============================================================
   STOCK LEVEL INDICATOR
   ============================================================ */
.stock-bar {
  width: 80px;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}
.stock-ok     { background: var(--success); }
.stock-low    { background: var(--warning); }
.stock-critical { background: var(--danger); }

/* ============================================================
   NOTIFICATIONS DROPDOWN
   ============================================================ */
.notif-dropdown {
  position: absolute;
  top: calc(var(--topbar-height) + 4px);
  right: 0;
  width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: none;
  animation: slideDown .2s ease;
}
.notif-dropdown.open { display: block; }

.notif-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: .9rem;
}

.notif-list { max-height: 320px; overflow-y: auto; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-surface-2); }
.notif-item.unread { background: rgba(37,99,235,.04); }

.notif-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
}
.notif-text { flex: 1; }
.notif-title { font-size: .82rem; font-weight: 600; color: var(--text-primary); }
.notif-msg { font-size: .76rem; color: var(--text-secondary); margin-top: 1px; }
.notif-time { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

.skeleton {
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-surface-2) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-left    { text-align: left; }
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--brand-primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold      { font-weight: 700; }
.fw-semibold  { font-weight: 600; }
.fz-sm        { font-size: .8rem; }
.fz-xs        { font-size: .72rem; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-none { display: none; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.rounded { border-radius: var(--radius-sm); }
.shadow  { box-shadow: var(--shadow-md); }

/* Color dot indicator */
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-success  { background: var(--success); }
.dot-danger   { background: var(--danger); }
.dot-warning  { background: var(--warning); }
.dot-info     { background: var(--info); }
.dot-secondary{ background: var(--secondary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .form-row-4 { grid-template-columns: repeat(2, 1fr); }
}

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

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}

/* ============================================================
   PRINT STYLES (imported by print.css too)
   ============================================================ */
@media print {
  .sidebar, .topbar, .page-header-actions,
  .filters-bar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ============================================================
   INSTALL WIZARD
   ============================================================ */
.install-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  padding: 20px;
}

.install-card {
  width: 100%;
  max-width: 640px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.install-header {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  padding: 32px;
  text-align: center;
  color: white;
}

.install-logo {
  width: 64px; height: 64px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 16px;
  backdrop-filter: blur(10px);
}

.install-steps {
  display: flex;
  gap: 0;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-color);
}

.install-step {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.install-step.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}
.install-step.done {
  color: var(--success);
  border-bottom-color: var(--success);
}

.install-body { padding: 32px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0a1628 100%);
}

.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
}

.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 70%, rgba(37,99,235,.15), transparent 60%);
}

.login-promo {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 400px;
  color: white;
}

.login-promo h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-promo p {
  color: #64748b;
  font-size: .95rem;
  line-height: 1.7;
}

.login-features {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  width: 100%;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
  color: #94a3b8;
}
.login-feature-icon {
  width: 28px; height: 28px;
  background: rgba(37,99,235,.2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  color: var(--brand-primary);
  flex-shrink: 0;
}

.login-right {
  width: 420px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card { width: 100%; }

.login-card-header {
  margin-bottom: 28px;
}
.login-card-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}

@media (max-width: 768px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: fit-content;
  margin-bottom: 14px;
}

.tab-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  transition: var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.tab-btn.active {
  background: var(--brand-primary);
  color: white;
  font-weight: 600;
}

/* ============================================================
   STOCK BAR
   ============================================================ */
.stock-bar {
  width: 80px;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s ease;
}
.stock-ok { background: var(--success); }
.stock-low { background: var(--warning); }
.stock-critical { background: var(--danger); }

/* ============================================================
   PRICE COMPARE WIDGET
   ============================================================ */
.price-compare {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: .75rem;
}
.price-compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  gap: 12px;
}
.price-compare-label { color: var(--text-muted); }
.price-compare-value { font-weight: 600; }
.price-up { color: var(--danger); }
.price-down { color: var(--success); }
.price-same { color: var(--text-muted); }

/* ============================================================
   INSTALL WIZARD
   ============================================================ */
.install-wrap {
  min-height: 100vh;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.install-card {
  width: 100%;
  max-width: 720px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.install-header {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: white;
  padding: 32px 40px;
  text-align: center;
}

.install-logo {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,.2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 16px;
}

.install-steps {
  display: flex;
  gap: 0;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-color);
}

.install-step {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.install-step:last-child { border-right: none; }
.install-step.active {
  color: var(--brand-primary);
  background: rgba(37,99,235,.06);
}
.install-step.done {
  color: var(--success);
}

.install-body { padding: 32px 40px; }

/* ============================================================
   NOTIFICATIONS DROPDOWN
   ============================================================ */
.notif-dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: none;
  animation: slideDown .2s ease;
}

.notif-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: .875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notif-list {
  max-height: 380px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background .15s;
}
.notif-item:hover { background: var(--bg-surface-2); }
.notif-item.unread { background: rgba(37,99,235,.04); }

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
}

/* ============================================================
   GLOBAL SEARCH RESULTS
   ============================================================ */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: none;
  animation: slideDown .15s ease;
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--border-color);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-surface-2); }

.search-result-type {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface-2);
  color: var(--text-muted);
  flex-shrink: 0;
  width: 56px;
  text-align: center;
}

.search-result-name { font-weight: 600; font-size: .85rem; }
.search-result-sub { font-size: .75rem; color: var(--text-muted); }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header-left {}
.page-header-left h1 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--brand-primary); }
.breadcrumb-sep { color: var(--border-color-2); }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* ============================================================
   HELPERS
   ============================================================ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.w-100 { width: 100%; }
.mb-0 { margin-bottom: 0 !important; }
.mt-auto { margin-top: auto; }

.bg-danger-light  { background: rgba(220,38,38,.05) !important; }
.bg-warning-light { background: rgba(217,119,6,.05) !important; }
.bg-success-light { background: rgba(22,163,74,.05) !important; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ============================================================
   ERROR PAGES
   ============================================================ */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px;
}
.error-code {
  font-size: 6rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 16px;
}
.error-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.error-msg { color: var(--text-secondary); font-size: .9rem; max-width: 400px; margin-bottom: 24px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .page-content { padding: 16px; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 1.2rem; }
  .page-header { flex-direction: column; }
  .page-header-actions { width: 100%; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}

