/* ============================================================
DESIGN TOKENS (CSS Variables)
============================================================ */
:root {
  /* Brand Colors */
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-light: #eef2ff;
  --color-success: #10b981;
  --color-success-hover: #059669;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;

  /* Neutral Palette (Slate) */
  --color-slate-50: #f8fafc;
  --color-slate-100: #f1f5f9;
  --color-slate-200: #e2e8f0;
  --color-slate-300: #cbd5e1;
  --color-slate-400: #94a3b8;
  --color-slate-500: #64748b;
  --color-slate-600: #475569;
  --color-slate-700: #334155;
  --color-slate-800: #1e293b;
  --color-slate-900: #0f172a;

  /* Semantic Colors */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-sidebar: #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-border: #e2e8f0;
  --color-border-focus: #6366f1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 10px 10px -5px rgba(15, 23, 42, 0.04);

  /* Spacing (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-base: 14px;
  --font-size-md: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
}

/* ============================================================
DARK MODE (will be activated in Step 2.5)
============================================================ */
/* ============================================================
DARK MODE
============================================================ */
[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-sidebar: #020617;
  --color-sidebar-hover: #1e293b;
  --color-text-primary: #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #64748b;
  --color-border: #334155;
  --color-border-focus: #6366f1;
  --color-primary-light: #312e81;

  /* Override Bootstrap's internal color variables */
  --bs-body-color: #f1f5f9;
  --bs-body-bg: #0f172a;
  --bs-emphasis-color: #f1f5f9;
  --bs-secondary-color: #cbd5e1;
  --bs-secondary-bg: #1e293b;
  --bs-tertiary-color: #64748b;
  --bs-tertiary-bg: #0f172a;
  --bs-border-color: #334155;
  --bs-primary: #6366f1;
  --bs-table-color: #f1f5f9;
  --bs-table-bg: transparent;
  --bs-table-border-color: #334155;
  --bs-table-striped-color: #f1f5f9;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-color: #f1f5f9;
  --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
}

/* Force text color on all common elements in dark mode */
[data-theme="dark"] body,
[data-theme="dark"] div,
[data-theme="dark"] span,
[data-theme="dark"] p,
[data-theme="dark"] td,
[data-theme="dark"] th,
[data-theme="dark"] label,
[data-theme="dark"] small,
[data-theme="dark"] strong,
[data-theme="dark"] li,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
  color: var(--color-text-primary);
}

/* Keep muted text muted (not pure white) */
[data-theme="dark"] .text-muted {
  color: var(--color-text-muted) !important;
}

[data-theme="dark"] .text-secondary {
  color: var(--color-text-secondary) !important;
}

/* Table specific overrides */
[data-theme="dark"] .table {
  color: var(--color-text-primary);
  --bs-table-color: var(--color-text-primary);
}

[data-theme="dark"] .table thead th {
  background: var(--color-slate-800) !important;
  color: var(--color-text-muted) !important;
  border-bottom-color: var(--color-border) !important;
}

[data-theme="dark"] .table tbody tr {
  background-color: transparent !important;
}

[data-theme="dark"] .table tbody tr:hover {
  background: var(--color-slate-800) !important;
}

/* Form controls in dark mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: var(--color-slate-800);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--color-text-muted);
}

/* Buttons outline variants in dark mode */
[data-theme="dark"] .btn-outline-secondary {
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  background: var(--color-slate-800);
}

[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--color-slate-700);
  color: var(--color-text-primary);
  border-color: var(--color-slate-600);
}

/* Topbar in dark mode */
[data-theme="dark"] .topbar {
  background: var(--color-surface);
  border-color: var(--color-border);
}

/* Cards in dark mode */
[data-theme="dark"] .card-box {
  background: var(--color-surface);
  border-color: var(--color-border);
}

/* Modal footer background */
[data-theme="dark"] #modalFooter {
  background: var(--color-slate-800) !important;
}

/* Alert in dark mode */
[data-theme="dark"] .alert-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Input readonly in dark mode */
[data-theme="dark"] input[readonly] {
  background-color: var(--color-slate-800) !important;
  color: var(--color-text-muted) !important;
}

/* ============================================================
GLOBAL RESETS
============================================================ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition-base), color var(--transition-base);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  background-image: linear-gradient(180deg, #0f172a 0%, #020617 100%);
  color: #e2e8f0;
  padding: var(--space-5) var(--space-4);
  position: fixed; /* Changed from sticky to fixed */
  top: 0;
  left: 0;
  bottom: 0; /* Stretches to full height */
  height: 100%; /* Ensures it fills the screen during zoom */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.main {
  flex: 1;
  padding: var(--space-6);
  min-width: 0;
  margin-left: var(--sidebar-width); /* Pushes main content next to fixed sidebar */
}

/* ============================================================
SIDEBAR
============================================================ */
/* Nav container — scrollable if too many items */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -8px;
  padding: 0 8px;
}

/* Style the scrollbar in the nav */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.brand {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-extrabold);
  margin-bottom: var(--space-6);
  color: #fff;
  letter-spacing: -0.025em;
  padding: 0 var(--space-2);
}

.nav-btn {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
  transition: all var(--transition-fast);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
}

.nav-btn:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.nav-btn.active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-btn.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============================================================
TOPBAR / HEADER
============================================================ */
.topbar {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.topbar strong {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

/* ============================================================
CARDS
============================================================ */
.card-box {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  transition: box-shadow var(--transition-base);
}

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

/* ============================================================
STATS GRID (Dashboard)
============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stats-grid .card-box {
  padding: var(--space-5);
}

.stats-grid .card-box > div:first-child {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.stats-grid .card-box h3,
.stats-grid .card-box h4 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0;
}

/* ============================================================
BUTTONS (override Bootstrap)
============================================================ */
.btn {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
}

.btn-success:hover {
  background: var(--color-success-hover);
  border-color: var(--color-success-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-outline-primary {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--color-primary);
  color: #fff;
}

.btn-outline-secondary {
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  background: var(--color-surface);
}

.btn-outline-secondary:hover {
  background: var(--color-slate-100);
  color: var(--color-text-primary);
  border-color: var(--color-slate-300);
}

.btn-outline-danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: transparent;
}

.btn-outline-danger:hover {
  background: var(--color-danger);
  color: #fff;
}

.btn-outline-warning {
  color: var(--color-warning);
  border-color: var(--color-warning);
  background: transparent;
}

.btn-outline-warning:hover {
  background: var(--color-warning);
  color: #fff;
}

.btn-outline-info {
  color: var(--color-info);
  border-color: var(--color-info);
  background: transparent;
}

.btn-outline-info:hover {
  background: var(--color-info);
  color: #fff;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ============================================================
FORM CONTROLS (override Bootstrap)
============================================================ */
.form-control,
.form-select {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  outline: none;
}

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

.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

/* ============================================================
TABLES
============================================================ */
.table {
  margin-bottom: 0;
  color: var(--color-text-primary);
}

.table > :not(caption) > * > * {
  padding: var(--space-3) var(--space-4);
  background-color: transparent;
  border-bottom: 1px solid var(--color-border);
}

.table thead th {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-slate-50);
}

[data-theme="dark"] .table thead th {
  background: var(--color-slate-800);
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--color-slate-50);
}

[data-theme="dark"] .table tbody tr:hover {
  background: var(--color-slate-800);
}

.table-sm > :not(caption) > * > * {
  padding: var(--space-2) var(--space-3);
}

/* ============================================================
USER BADGE
============================================================ */
#userBadge {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
  padding: var(--space-2) var(--space-3);
  background: var(--color-slate-100);
  border-radius: var(--radius-full);
}

[data-theme="dark"] #userBadge {
  background: var(--color-slate-800);
}

/* ============================================================
ALERTS
============================================================ */
.alert {
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-base);
  border: 1px solid transparent;
}

.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

[data-theme="dark"] .alert-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ============================================================
TEXT HELPERS
============================================================ */
.text-muted {
  color: var(--color-text-muted) !important;
}

.text-secondary {
  color: var(--color-text-secondary) !important;
}

/* ============================================================
RESPONSIVE — Sidebar Collapse on Narrow Screens
============================================================ */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: var(--space-4);
  }
}

@media (max-width: 768px) {
  /* Collapse sidebar to icons only */
  .sidebar {
    width: 64px;
    padding: var(--space-4) var(--space-2);
  }

  .main {
    margin-left: 64px; /* Match collapsed sidebar width */
  }

  .brand {
    padding: 0;
  }

  .brand span {
    justify-content: center;
    font-size: 0;
  }

  .brand svg {
    width: 24px;
    height: 24px;
  }

  .nav-section-label {
    text-align: center;
    font-size: 0;
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin: 8px 0;
  }

  .nav-btn {
    justify-content: center;
    padding: 12px;
  }

  .nav-btn span {
    display: none;
  }

  .nav-btn i {
    width: 22px !important;
    height: 22px !important;
  }

  .nav-btn.active::before {
    display: none;
  }

  .user-info {
    display: none;
  }

  .user-profile {
    justify-content: center;
    padding: 8px;
  }

  .sidebar-footer {
    padding-top: 12px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
SCROLLBAR STYLING (subtle premium touch)
============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-slate-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-slate-400);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--color-slate-700);
}

/* ============================================================
SELECTION
============================================================ */
::selection {
  background: rgba(99, 102, 241, 0.2);
  color: var(--color-text-primary);
}

/* ============================================================
LINKS
============================================================ */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

/* ============================================================
LOADING SKELETONS
============================================================ */
.skeleton {
  background: linear-gradient(90deg, 
    var(--color-slate-100) 0%, 
    var(--color-slate-200) 50%, 
    var(--color-slate-100) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
  display: inline-block;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-text.lg { height: 28px; width: 80px; }
.skeleton-text.md { height: 16px; width: 120px; }
.skeleton-text.sm { height: 12px; width: 60px; }
.skeleton-text.full { width: 100%; }

.skeleton-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(90deg, 
    var(--color-slate-100) 0%, 
    var(--color-slate-200) 50%, 
    var(--color-slate-100) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-row {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}

.skeleton-card {
  padding: 20px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
EMPTY STATES
============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--color-slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-slate-400);
}

.empty-state-icon svg {
  width: 36px;
  height: 36px;
}

.empty-state h4 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state .btn {
  margin-top: 4px;
}

[data-theme="dark"] .empty-state-icon {
  background: var(--color-slate-800);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, 
    var(--color-slate-800) 0%, 
    var(--color-slate-700) 50%, 
    var(--color-slate-800) 100%);
  background-size: 200% 100%;
}

/* ============================================================
CUSTOM DROPDOWN ARROW (works in light + dark mode)
============================================================ */

/* Remove Bootstrap's default arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 16px center !important;
  background-size: 16px 16px !important;
  padding-right: 40px !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
}

/* Dark mode arrow (lighter color) */
[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") !important;
}

/* Hover effect on select */
.form-select:hover {
  border-color: var(--color-slate-400) !important;
}

/* Focus state keeps the arrow visible */
.form-select:focus {
  border-color: var(--color-primary) !important;
}

/* ============================================================
SIDEBAR PREMIUM STYLING
============================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 0 16px;
  margin-bottom: 8px;
}

.nav-btn {
  position: relative;
  overflow: hidden;
}

.nav-btn span {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
}

/* Sidebar Footer (pushed to bottom) */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* User Profile Card */
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  transition: background 150ms ease;
}

.user-profile:hover {
  background: rgba(255, 255, 255, 0.06);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: #94a3b8;
  text-transform: capitalize;
  margin-top: 2px;
}

/* Dark mode sidebar adjustments */
[data-theme="dark"] .nav-section-label {
  color: #475569;
}

[data-theme="dark"] .sidebar-footer {
  border-top-color: rgba(255, 255, 255, 0.06);
}

/* Responsive: collapse to icons only on small screens */
@media (max-width: 768px) {
  .sidebar {
    width: 64px;
    padding: 16px 8px;
  }

/* Nav container — scrollable if too many items */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -8px;
  padding: 0 8px;
}

/* Style the scrollbar in the nav */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

  .brand {
    justify-content: center;
  }

  .brand span {
    justify-content: center;
    font-size: 0;
  }

  .brand svg {
    width: 24px;
    height: 24px;
  }

  .nav-section-label {
    text-align: center;
    font-size: 0;
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin: 8px 0;
  }

  .nav-btn {
    justify-content: center;
    padding: 12px;
  }

  .nav-btn span {
    display: none;
  }

  .nav-btn i {
    width: 22px !important;
    height: 22px !important;
  }

  .nav-btn.active::before {
    display: none;
  }

  .user-info {
    display: none;
  }

  .user-profile {
    justify-content: center;
    padding: 8px;
  }
}

/* ============================================================
BREADCRUMBS
============================================================ */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
  min-height: 20px;
  flex-wrap: wrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
  font-weight: 500;
  transition: color 150ms ease;
}

.breadcrumb-item.clickable {
  cursor: pointer;
}

.breadcrumb-item.clickable:hover {
  color: var(--color-primary);
}

.breadcrumb-item.active {
  color: var(--color-text-primary);
  font-weight: 600;
}

.breadcrumb-separator {
  color: var(--color-text-muted);
  opacity: 0.5;
  user-select: none;
}

.breadcrumb-item svg {
  width: 14px;
  height: 14px;
}

/* Dark mode adjustments */
[data-theme="dark"] .breadcrumb-item {
  color: var(--color-text-muted);
}

[data-theme="dark"] .breadcrumb-item.active {
  color: var(--color-text-primary);
}

/* Responsive: hide on very small screens */
@media (max-width: 600px) {
  .breadcrumbs {
    font-size: 12px;
  }
  
  .breadcrumb-item {
    gap: 4px;
  }
  
  .breadcrumb-separator {
    margin: 0 2px;
  }
}

/* ============================================================
REAL-TIME FORM VALIDATION
============================================================ */

/* Valid field — subtle green tint */
.form-control.is-valid,
.form-select.is-valid {
  border-color: var(--color-success) !important;
  background-image: none !important;
  padding-right: 40px !important;
}

.form-control.is-valid:focus,
.form-select.is-valid:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* Invalid field — red border */
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--color-danger) !important;
  background-image: none !important;
  padding-right: 40px !important;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Validation icons (positioned inside the field) */
.validation-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  pointer-events: none;
  display: none;
}

.validation-icon.valid { color: var(--color-success); display: block; }
.validation-icon.invalid { color: var(--color-danger); display: block; }

.validation-icon svg { width: 18px; height: 18px; }

/* Validation feedback message */
.validation-feedback {
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
  display: block;
}

.validation-feedback.valid { color: var(--color-success); }
.validation-feedback.invalid { color: var(--color-danger); }

/* Form group wrapper for positioning icons */
.form-group-valid {
  position: relative;
}

/* Disabled save button styling */
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Dark mode adjustments */
[data-theme="dark"] .form-control.is-valid,
[data-theme="dark"] .form-select.is-valid {
  border-color: var(--color-success) !important;
}

[data-theme="dark"] .form-control.is-invalid,
[data-theme="dark"] .form-select.is-invalid {
  border-color: var(--color-danger) !important;
}

/* ============================================================
HEADER SEARCH BUTTON RESPONSIVE
============================================================ */
/* Show search label on wider screens */
@media (min-width: 1100px) {
  .search-label-text { display: inline !important; }
}

/* Hide labels on small screens to save space */
@media (max-width: 768px) {
  .logout-label-text { display: none; }
}

/* ============================================================
KBD ELEMENT DARK MODE FIX
============================================================ */
/* In dark mode, kbd elements need explicit dark styling
   because raw slate variables don't auto-invert */
[data-theme="dark"] kbd {
  background: var(--color-slate-800) !important;
  border-color: var(--color-slate-700) !important;
  color: var(--color-text-secondary) !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3) !important;
}

/* Also fix the command palette footer kbd elements */
[data-theme="dark"] #cmdPaletteOverlay kbd {
  background: var(--color-slate-800) !important;
  border-color: var(--color-slate-700) !important;
  color: var(--color-text-secondary) !important;
}

/* ============================================================
GLOBAL KBD STYLING (shortcut buttons)
Ensures all <kbd> elements are visible in both light & dark modes
============================================================ */

/* Base light mode styling — overrides weak inline styles */
kbd {
  background: var(--color-slate-200) !important;
  border: 1px solid var(--color-slate-300) !important;
  color: var(--color-text-secondary) !important;
  box-shadow: 0 1px 0 var(--color-slate-300) !important;
  padding: 2px 8px !important;
  border-radius: 6px !important;
  font-family: var(--font-family) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  display: inline-block;
  line-height: 1.4;
}

/* Dark mode override — ensures dark background with light text */
[data-theme="dark"] kbd {
  background: var(--color-slate-800) !important;
  border: 1px solid var(--color-slate-700) !important;
  color: var(--color-text-secondary) !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3) !important;
}

/* ============================================================
AUDIT LOG ACTION BADGE
============================================================ */
.audit-action-badge {
  font-family: monospace;
  font-size: 12px;
  background: var(--color-slate-100);
  color: var(--color-text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

[data-theme="dark"] .audit-action-badge {
  background: var(--color-slate-800);
  color: var(--color-text-secondary);
}

/* ============================================================
USER MANAGEMENT ROLE BADGE
============================================================ */
.role-badge {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--color-slate-100);
  color: var(--color-text-secondary);
  display: inline-block;
}

[data-theme="dark"] .role-badge {
  background: var(--color-slate-800);
  color: var(--color-text-secondary);
}

/* ============================================================
EXAM GROUP BADGES (theme-adaptive)
============================================================ */
.eg-priority-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--color-slate-100);
  color: var(--color-text-secondary);
  border-radius: 12px;
  font-weight: 600;
}

[data-theme="dark"] .eg-priority-badge {
  background: var(--color-slate-800);
  color: var(--color-text-secondary);
}

.eg-theme-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid currentColor;
}

.eg-id-code {
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: monospace;
  margin-bottom: 8px;
}

[data-theme="dark"] .eg-id-code {
  color: var(--color-text-muted);
}

/* ============================================================
TABLE ACTION BUTTONS — Bulletproof visibility
============================================================ */
.action-btn {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  padding: 0 !important;
  border: 1px solid var(--color-slate-300) !important;
  background: var(--color-slate-100) !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 150ms ease !important;
  margin: 0 2px !important;
  vertical-align: middle !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
}

.action-btn:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
}

.action-btn svg,
.action-btn i {
  width: 16px !important;
  height: 16px !important;
  stroke-width: 2 !important;
}

/* Edit button — indigo */
.action-btn-edit {
  color: #4f46e5 !important;
  border-color: #c7d2fe !important;
  background: #eef2ff !important;
}
.action-btn-edit:hover {
  background: #4f46e5 !important;
  color: #fff !important;
  border-color: #4f46e5 !important;
}
.action-btn-edit svg { stroke: #4f46e5 !important; }
.action-btn-edit:hover svg { stroke: #fff !important; }

/* Preview button — blue */
.action-btn-preview {
  color: #2563eb !important;
  border-color: #bfdbfe !important;
  background: #eff6ff !important;
}
.action-btn-preview:hover {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}
.action-btn-preview svg { stroke: #2563eb !important; }
.action-btn-preview:hover svg { stroke: #fff !important; }

/* Publish button — green */
.action-btn-publish {
  color: #059669 !important;
  border-color: #a7f3d0 !important;
  background: #ecfdf5 !important;
}
.action-btn-publish:hover {
  background: #059669 !important;
  color: #fff !important;
  border-color: #059669 !important;
}
.action-btn-publish svg { stroke: #059669 !important; }
.action-btn-publish:hover svg { stroke: #fff !important; }

/* Delete button — red */
.action-btn-delete {
  color: #dc2626 !important;
  border-color: #fecaca !important;
  background: #fef2f2 !important;
}
.action-btn-delete:hover {
  background: #dc2626 !important;
  color: #fff !important;
  border-color: #dc2626 !important;
}
.action-btn-delete svg { stroke: #dc2626 !important; }
.action-btn-delete:hover svg { stroke: #fff !important; }

/* Dark Mode */
[data-theme="dark"] .action-btn {
  border-color: #475569 !important;
  background: #1e293b !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
}

[data-theme="dark"] .action-btn-edit {
  color: #a5b4fc !important;
  border-color: #3730a3 !important;
  background: #312e81 !important;
}
.action-btn-edit:hover {
  background: #4f46e5 !important;
  color: #fff !important;
}
[data-theme="dark"] .action-btn-edit svg { stroke: #a5b4fc !important; }
[data-theme="dark"] .action-btn-edit:hover svg { stroke: #fff !important; }

[data-theme="dark"] .action-btn-preview {
  color: #93c5fd !important;
  border-color: #1e40af !important;
  background: #1e3a8a !important;
}
[data-theme="dark"] .action-btn-preview:hover {
  background: #2563eb !important;
  color: #fff !important;
}
[data-theme="dark"] .action-btn-preview svg { stroke: #93c5fd !important; }
[data-theme="dark"] .action-btn-preview:hover svg { stroke: #fff !important; }

[data-theme="dark"] .action-btn-publish {
  color: #6ee7b7 !important;
  border-color: #065f46 !important;
  background: #064e3b !important;
}
[data-theme="dark"] .action-btn-publish:hover {
  background: #059669 !important;
  color: #fff !important;
}
[data-theme="dark"] .action-btn-publish svg { stroke: #6ee7b7 !important; }
[data-theme="dark"] .action-btn-publish:hover svg { stroke: #fff !important; }

[data-theme="dark"] .action-btn-delete {
  color: #fca5a5 !important;
  border-color: #991b1b !important;
  background: #7f1d1d !important;
}
[data-theme="dark"] .action-btn-delete:hover {
  background: #dc2626 !important;
  color: #fff !important;
}
[data-theme="dark"] .action-btn-delete svg { stroke: #fca5a5 !important; }
[data-theme="dark"] .action-btn-delete:hover svg { stroke: #fff !important; }

/* ============================================================
DASHBOARD DARK MODE TEXT FIX
============================================================ */
[data-theme="dark"] .stats-grid .card-box,
[data-theme="dark"] .stats-grid .card-box div,
[data-theme="dark"] .stats-grid .card-box h3,
[data-theme="dark"] .stats-grid .card-box h4 {
  color: #ffffff !important;
}

[data-theme="dark"] .stats-grid .card-box div[style*="color"] {
  color: #e2e8f0 !important; /* Slightly lighter for sub-stats */
}

[data-theme="dark"] .card-box h5 {
  color: #ffffff !important;
}

/* ============================================================
DRAG AND DROP REORDERING
============================================================ */
.reorder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: grab;
  transition: all 150ms ease;
}

.reorder-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.reorder-item:active {
  cursor: grabbing;
}

.sortable-ghost {
  opacity: 0.4;
  background: var(--color-primary-light) !important;
  border-color: var(--color-primary) !important;
}

.sortable-chosen {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.drag-handle {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ============================================================
QUILL RICH TEXT EDITOR
============================================================ */
.ql-toolbar {
  border: 1px solid var(--color-border) !important;
  border-bottom: none !important;
  border-radius: 8px 8px 0 0 !important;
  background: var(--color-slate-50) !important;
}

[data-theme="dark"] .ql-toolbar {
  background: var(--color-slate-800) !important;
  border-color: var(--color-slate-700) !important;
}

.ql-container {
  border: 1px solid var(--color-border) !important;
  border-radius: 0 0 8px 8px !important;
  min-height: 100px !important;
  font-family: var(--font-family) !important;
  font-size: 14px !important;
}

[data-theme="dark"] .ql-container {
  border-color: var(--color-slate-700) !important;
  background: var(--color-slate-800) !important;
  color: var(--color-text-primary) !important;
}

.ql-editor {
  color: var(--color-text-primary) !important;
}

.ql-snow .ql-stroke {
  stroke: var(--color-text-secondary) !important;
}

[data-theme="dark"] .ql-snow .ql-stroke {
  stroke: #cbd5e1 !important;
}

.ql-snow .ql-fill {
  fill: var(--color-text-secondary) !important;
}

[data-theme="dark"] .ql-snow .ql-fill {
  fill: #cbd5e1 !important;
}

.ql-snow .ql-picker {
  color: var(--color-text-secondary) !important;
}

/* Compact Table Density */
.density-compact .table > :not(caption) > * > * {
  padding: 4px 8px !important;
  font-size: 13px;
}

.density-compact .card-box {
  padding: 12px;
}

/* ============================================================
SOFT VALIDATION (Green border for filled fields)
============================================================ */
.form-control.is-filled, .form-select.is-filled {
  border-color: var(--color-success) !important;
}

.form-control.is-filled:focus, .form-select.is-filled:focus {
  border-color: var(--color-success) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* ============================================================
SOFT VALIDATION (Quill Editor Green border)
============================================================ */
.ql-container.is-filled {
  border-color: var(--color-success) !important;
}

.ql-container.is-filled.ql-focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

.imp-dropzone {
  border: 2px dashed var(--color-border, #cbd5e1);
  border-radius: 8px;
  padding: 10px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--color-slate-50, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
}
.imp-dropzone:hover {
  border-color: var(--color-primary, #4f46e5);
  background: var(--color-primary-light, #eef2ff);
}
.imp-dropzone.dragover {
  border-color: var(--color-primary, #4f46e5);
  background: var(--color-primary-light, #eef2ff);
  transform: scale(1.005);
}
.imp-dropzone.invalid {
  border-color: var(--color-danger, #dc2626);
  background: #fef2f2;
}
.imp-dropzone-icon {
  font-size: 20px;
  margin: 0;
  line-height: 1;
}
.imp-dropzone-text {
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
  margin: 0;
}
.imp-dropzone-text strong {
  color: var(--color-primary, #4f46e5);
}

/* PREMIUM TYPOGRAPHY FOR JOB PREVIEW - Quill Cleanup */
.cms-job-description { color: var(--color-text-secondary); line-height: 1.6; font-size: 15px; display: block; word-wrap: break-word; overflow: hidden; }
.cms-job-description * { margin: 0; padding: 0; box-sizing: border-box; }

/* Forcefully hide any empty tags to prevent vertical gaps */
.cms-job-description p:empty,
.cms-job-description div:empty,
.cms-job-description p:has(br:only-child) { display: none !important; }

.cms-job-description p { margin: 0 0 12px 0; }
.cms-job-description h2 { font-family: var(--font-heading); font-size: 18px; font-weight: 700; color: var(--color-text-primary); margin: 24px 0 12px; padding-left: 10px; border-left: 4px solid var(--color-primary); }
.cms-job-description h3 { font-family: var(--font-heading); font-size: 16px; font-weight: 600; color: var(--color-text-primary); margin: 20px 0 10px; }

.cms-job-description ul, .cms-job-description ol { padding-left: 24px; margin: 0 0 12px 0; }
.cms-job-description li { margin-bottom: 6px; }
.cms-job-description a { color: var(--color-primary); text-decoration: underline; font-weight: 500; }
.cms-job-description strong { color: var(--color-text-primary); font-weight: 700; }

.cms-job-description table { width: 100%; border-collapse: collapse; margin: 0 0 12px 0; font-size: 14px; display: block; overflow-x: auto; white-space: nowrap; }
.cms-job-description th, .cms-job-description td { border: 1px solid var(--color-border); padding: 10px 14px; text-align: left; }
.cms-job-description th { background: var(--color-slate-100); font-weight: 700; color: var(--color-text-primary); }
.cms-job-description tr:nth-child(even) { background: var(--color-slate-50); }
[data-theme="dark"] .cms-job-description th { background: var(--color-slate-800); }
[data-theme="dark"] .cms-job-description tr:nth-child(even) { background: var(--color-slate-800); }