/* ============================================================
   Perfect Communication CRM ERP — Main Stylesheet
   Design: Modern SaaS (Zoho/ERPNext inspired)
   ============================================================ */

/* ─── CSS Variables (Light Theme) ──────────────────────────── */
:root {
  --primary:        #3182ce;
  --primary-light:  #4299e1;
  --primary-dark:   #2b6cb0;
  --primary-bg:     #ebf8ff;
  --secondary:      #0ea5e9;
  --secondary-bg:   #e0f2fe;
  --success:        #10b981;
  --success-bg:     #d1fae5;
  --warning:        #f59e0b;
  --warning-bg:     #fef3c7;
  --danger:         #ef4444;
  --danger-bg:      #fee2e2;
  --info:           #06b6d4;
  --info-bg:        #cffafe;

  --body-bg:        #f1f5f9;
  --card-bg:        #ffffff;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

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

  --sidebar-bg:     #ffffff;
  --sidebar-text:   #4a5568;
  --sidebar-active: #dbeafe;
  --sidebar-hover:  #eff6ff;
  --sidebar-width:  260px;
  --sidebar-collapsed: 68px;
  --topbar-height:  64px;

  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --radius-xl:      24px;

  --shadow-xs:      0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:      0 2px 8px rgba(0,0,0,.08);
  --shadow:         0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.14);

  --font-sans:      'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  --transition:     all .2s ease;
}

/* ─── Dark Mode ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --body-bg:        #0f172a;
  --card-bg:        #1e293b;
  --border:         #334155;
  --border-light:   #1e293b;
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --primary-bg:     #1a365d;
  --sidebar-bg:     #1e293b;
  --sidebar-text:   #94a3b8;
  --sidebar-active: rgba(49,130,206,.25);
  --sidebar-hover:  rgba(49,130,206,.12);
  --sidebar-shadow: 4px 0 24px rgba(49,130,206,.25), 2px 0 8px rgba(49,130,206,.12);
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--body-bg);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}

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

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

/* ─── SIDEBAR ───────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(49,130,206,.2);
  box-shadow: 4px 0 24px rgba(49,130,206,.15), 2px 0 8px rgba(49,130,206,.08);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1040;
  transition: width .3s cubic-bezier(.4,0,.2,1), left .3s cubic-bezier(.4,0,.2,1);
  overflow: visible;
}
.sidebar-nav { overflow-y: auto; overflow-x: hidden; }

#sidebar.collapsed { width: var(--sidebar-collapsed); }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 700; font-size: 16px; color: white;
}

.sidebar-brand .brand-text { overflow: hidden; }
.sidebar-brand .brand-text h5 {
  font-size: 13px; font-weight: 700;
  color: var(--text-primary); line-height: 1.2;
  letter-spacing: .3px;
}
.sidebar-brand .brand-text small {
  font-size: 10px; color: var(--text-muted);
  opacity: .9; text-transform: uppercase; letter-spacing: 1px;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 18px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s;
}
#sidebar.collapsed .nav-section-title { opacity: 0; }

.sidebar-item { position: relative; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #1a202c;
}

.sidebar-link.active {
  background: #3182ce;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(49,130,206,.35);
  border-left: none;
  margin-left: 8px;
  padding-left: 16px;
}

.sidebar-link .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.sidebar-link .nav-label { flex: 1; }

.sidebar-link .nav-badge {
  font-size: 10px;
  background: var(--danger);
  color: white;
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-link .nav-arrow {
  font-size: 12px;
  opacity: .6;
  transition: transform .2s;
  flex-shrink: 0;
}
.sidebar-link[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }

/* Sub menu */
.sidebar-submenu {
  list-style: none;
  padding: 0;
  overflow: hidden;
}

.sidebar-submenu .sidebar-link {
  font-size: 12.5px;
  padding: 8px 16px 8px 44px;
  font-weight: 400;
  color: #4a5568;
  margin: 1px 8px;
  position: relative;
}
.sidebar-submenu .sidebar-link::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #94a3b8;
}
.sidebar-submenu .sidebar-link:hover { background: #eff6ff; color: #1a202c; }
.sidebar-submenu .sidebar-link:hover::before { background: #3182ce; }
.sidebar-submenu .sidebar-link.active { background: #3182ce; color: #ffffff; font-weight: 600; }
.sidebar-submenu .sidebar-link.active::before { background: #ffffff; }

/* Collapsed tooltip */
#sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 10px;
  margin: 2px auto;
  width: 44px;
}
#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-arrow,
#sidebar.collapsed .nav-badge { display: none; }
#sidebar.collapsed .sidebar-submenu { display: none !important; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: var(--transition);
}
.sidebar-footer .user-card:hover { background: var(--sidebar-hover); }
.sidebar-footer .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-footer .user-info { overflow: hidden; }
.sidebar-footer .user-info strong { font-size: 12px; color: var(--text-primary); display: block; }
.sidebar-footer .user-info small { font-size: 10px; color: var(--text-muted); }
#sidebar.collapsed .sidebar-footer .user-info { display: none; }

/* ─── TOPBAR ────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 1030;
  transition: left .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-xs);
}

#sidebar.collapsed ~ #main-wrapper #topbar,
body.sidebar-collapsed #topbar { left: var(--sidebar-collapsed); }

.topbar-toggle {
  width: 36px; height: 36px;
  border: none; background: transparent;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  transition: var(--transition);
}
.topbar-toggle:hover { background: var(--body-bg); color: var(--text-primary); }

/* Search */
.topbar-search {
  flex: 1; max-width: 400px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--body-bg);
  border-radius: 99px;
  padding: 8px 16px 8px 40px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}
.topbar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49,130,206,.1);
  background: var(--card-bg);
}
.topbar-search .search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px;
}

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

/* Topbar icon buttons */
.topbar-btn {
  width: 38px; height: 38px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  position: relative;
  transition: var(--transition);
}
.topbar-btn:hover { background: var(--body-bg); color: var(--text-primary); }
.topbar-btn .badge-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--card-bg);
}

/* Profile dropdown */
.profile-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 4px 4px;
  border: none; background: transparent;
  border-radius: 99px;
  cursor: pointer;
  transition: var(--transition);
}
.profile-btn:hover { background: var(--body-bg); }
.profile-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: white; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.profile-info { text-align: left; }
.profile-info strong { font-size: 13px; color: var(--text-primary); font-weight: 600; display: block; }
.profile-info small { font-size: 11px; color: var(--text-muted); }

/* ─── MAIN CONTENT ──────────────────────────────────────────── */
#main-wrapper {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  transition: margin .3s cubic-bezier(.4,0,.2,1), width .3s;
  display: flex;
  flex-direction: column;
}

#sidebar.collapsed ~ #main-wrapper {
  margin-left: var(--sidebar-collapsed);
  width: calc(100% - var(--sidebar-collapsed));
}

#page-content {
  padding: 88px 24px 32px;
  flex: 1;
}

/* ─── PAGE HEADER ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.breadcrumb { font-size: 12px; }
.breadcrumb .breadcrumb-item + .breadcrumb-item::before { content: '›'; color: var(--text-muted); }
.breadcrumb .breadcrumb-item a { color: var(--text-muted); }
.breadcrumb .breadcrumb-item.active { color: var(--text-secondary); }

/* ─── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border-light); }

/* ─── STAT WIDGETS ──────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--primary));
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: var(--stat-bg, var(--primary-bg));
  color: var(--stat-color, var(--primary));
}
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.stat-change { font-size: 12px; margin-top: 6px; font-weight: 500; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; box-shadow: 0 4px 12px rgba(49,130,206,.35); }

.btn-secondary { background: var(--secondary); color: white; border-color: var(--secondary); }
.btn-secondary:hover { background: #0284c7; color: white; }

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

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

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

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

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

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 14px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ─── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 99px;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.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(--border-light); color: var(--text-secondary); }

/* ─── FORMS ─────────────────────────────────────────────────── */
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; display: block; }
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  display: block; width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  outline: none;
  line-height: 1.5;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49,130,206,.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 11.5px; color: var(--danger); margin-top: 4px; }

.input-group { position: relative; display: flex; }
.input-group .form-control { border-radius: 0; }
.input-group .form-control:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .form-control:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group-text {
  padding: 9px 12px;
  background: var(--body-bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* ─── TABLE ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
.table {
  width: 100%; border-collapse: collapse;
  font-size: 13px; color: var(--text-primary);
}
.table thead th {
  background: var(--body-bg);
  padding: 11px 14px;
  font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid var(--border-light); transition: background .1s; }
.table tbody tr:hover { background: var(--body-bg); }
.table tbody td { padding: 12px 14px; vertical-align: middle; }
.table tbody tr:last-child { border-bottom: none; }

/* DataTables override */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  background: var(--card-bg);
  color: var(--text-primary);
  outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--primary); }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-sm) !important;
  font-size: 12px !important;
  color: var(--text-secondary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}

/* ─── MODALS ────────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--card-bg);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border-light); }

/* ─── ALERTS ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: #fca5a5; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fcd34d; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: #67e8f9; }

/* ─── SKELETON LOADER ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 37%, var(--border-light) 63%);
  background-size: 400% 100%;
  animation: skeleton-wave 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

/* ─── SPINNER ───────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── PAGE LOADER ───────────────────────────────────────────── */
#page-loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
  transition: opacity .3s;
}
[data-theme="dark"] #page-loader { background: rgba(15,23,42,.85); }

/* ─── Dark Mode Sidebar ─────────────────────────────────────── */
[data-theme="dark"] #sidebar {
  background: #1e293b;
  border-right: 1px solid #334155;
  box-shadow: 4px 0 24px rgba(49,130,206,.25), 2px 0 8px rgba(49,130,206,.12);
}
[data-theme="dark"] .sidebar-brand { border-bottom-color: #334155; }
[data-theme="dark"] .sidebar-brand .brand-text h5 { color: #f1f5f9; }
[data-theme="dark"] .sidebar-brand .brand-text small { color: #64748b; }
[data-theme="dark"] .nav-section-title { color: #475569; }
[data-theme="dark"] .sidebar-link { color: #94a3b8; }
[data-theme="dark"] .sidebar-link:hover { background: rgba(49,130,206,.12); color: #f1f5f9; }
[data-theme="dark"] .sidebar-link.active { background: #3182ce; color: #ffffff; }
[data-theme="dark"] .sidebar-submenu .sidebar-link { color: #64748b; }
[data-theme="dark"] .sidebar-submenu .sidebar-link::before { background: #475569; }
[data-theme="dark"] .sidebar-submenu .sidebar-link:hover { background: rgba(49,130,206,.12); color: #f1f5f9; }
[data-theme="dark"] .sidebar-submenu .sidebar-link:hover::before { background: #3182ce; }
[data-theme="dark"] .sidebar-submenu .sidebar-link.active { background: #3182ce; color: #ffffff; }
[data-theme="dark"] .sidebar-footer { border-top-color: #334155; }
[data-theme="dark"] .sidebar-footer .user-card:hover { background: rgba(49,130,206,.12); }
[data-theme="dark"] .sidebar-footer .user-info strong { color: #f1f5f9; }
[data-theme="dark"] .sidebar-footer .user-info small { color: #64748b; }
#page-loader.hidden { opacity: 0; pointer-events: none; }

/* ─── TOAST NOTIFICATIONS ───────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 80px; right: 20px;
  z-index: 9000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 300px; max-width: 420px;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 12px;
  animation: slideIn .3s ease;
  position: relative;
}
.toast-item.success { border-left-color: var(--success); }
.toast-item.error   { border-left-color: var(--danger); }
.toast-item.warning { border-left-color: var(--warning); }
.toast-item .toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-item.success .toast-icon { color: var(--success); }
.toast-item.error   .toast-icon { color: var(--danger); }
.toast-item.warning .toast-icon { color: var(--warning); }
.toast-item .toast-body { flex: 1; }
.toast-item .toast-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.toast-item .toast-msg   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toast-item .toast-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; padding: 0; line-height: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ─── NOTIFICATION PANEL ────────────────────────────────────── */
.notif-dropdown {
  width: 360px;
  max-height: 480px;
  overflow-y: auto;
}
.notif-item {
  display: flex; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition);
}
.notif-item:hover { background: var(--body-bg); }
.notif-item.unread { background: var(--primary-bg); }
.notif-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
  background: var(--primary-bg); color: var(--primary);
}
.notif-text strong { font-size: 12.5px; display: block; }
.notif-text span { font-size: 11px; color: var(--text-muted); }

/* ─── CHARTS ────────────────────────────────────────────────── */
.chart-wrapper { position: relative; }
.chart-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.chart-subtitle { font-size: 12px; color: var(--text-muted); }

/* ─── UTILITIES ─────────────────────────────────────────────── */
.text-primary-color { color: var(--primary) !important; }
.text-success-color { color: var(--success) !important; }
.text-danger-color  { color: var(--danger)  !important; }
.text-warning-color { color: var(--warning) !important; }
.text-muted-custom  { color: var(--text-muted) !important; }
.text-secondary-custom { color: var(--text-secondary) !important; }
.bg-body { background: var(--body-bg) !important; }
.border-custom { border-color: var(--border) !important; }
.rounded-custom { border-radius: var(--radius) !important; }
.font-mono { font-family: var(--font-mono); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.gap-4px { gap: 4px; }

.divider { height: 1px; background: var(--border-light); margin: 16px 0; }
.avatar-circle {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}

/* ─── AUTH PAGES ────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a365d 0%, #2c5282 50%, #3182ce 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.auth-card {
  width: 100%; max-width: 440px;
  background: white;
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  position: relative;
  z-index: 1;
}

[data-theme="dark"] .auth-card { background: var(--card-bg); }

.auth-logo {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: white;
  margin: 0 auto 24px;
  box-shadow: 0 8px 24px rgba(49,130,206,.35);
}

.auth-title { font-size: 22px; font-weight: 700; color: var(--text-primary); text-align: center; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 4px; margin-bottom: 28px; }

/* ─── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 52px; opacity: .3; margin-bottom: 16px; display: block; }
.empty-state h5 { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: 13px; margin-top: 4px; }

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  #sidebar { width: var(--sidebar-collapsed); }
  #main-wrapper { margin-left: var(--sidebar-collapsed); width: calc(100% - var(--sidebar-collapsed)); }
  #topbar { left: var(--sidebar-collapsed); }
  #sidebar .nav-label,
  #sidebar .nav-arrow,
  #sidebar .sidebar-brand .brand-text,
  #sidebar .nav-section-title,
  #sidebar .sidebar-footer .user-info { display: none; }
  #sidebar .sidebar-link { justify-content: center; }
  #sidebar.open {
    width: var(--sidebar-width);
  }
  #sidebar.open .nav-label,
  #sidebar.open .nav-arrow,
  #sidebar.open .sidebar-brand .brand-text,
  #sidebar.open .nav-section-title,
  #sidebar.open .sidebar-footer .user-info { display: block; }
  #sidebar.open .sidebar-link { justify-content: flex-start; }
}

@media (max-width: 768px) {
  #sidebar {
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  #sidebar .nav-label, #sidebar .nav-arrow, #sidebar .sidebar-brand .brand-text,
  #sidebar .nav-section-title, #sidebar .sidebar-footer .user-info { display: block !important; }
  #sidebar .sidebar-link { justify-content: flex-start !important; }
  #sidebar.mobile-open { left: 0; }
  #sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1039; cursor: pointer; }
  #main-wrapper { margin-left: 0 !important; width: 100%; }
  #topbar { left: 0 !important; padding: 0 16px; }
  #page-content { padding: 80px 16px 24px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-search { display: none; }
  .stat-card { padding: 14px; }
}

/* ─── SELECT2 Override ──────────────────────────────────────── */
.select2-container--default .select2-selection--single {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  height: 38px !important;
  background: var(--card-bg) !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px !important;
  color: var(--text-primary) !important;
  font-size: 13px !important;
  padding-left: 10px !important;
}
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(49,130,206,.12) !important;
}
.select2-dropdown { border-color: var(--border) !important; font-size: 13px !important; }
.select2-results__option--highlighted { background: var(--primary) !important; }

/* ─── Print ─────────────────────────────────────────────────── */
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #main-wrapper { margin: 0 !important; width: 100% !important; }
  #page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
