/* ================================================================
   WEPS ADMIN — DESIGN SYSTEM
   Dark professional SaaS theme
================================================================ */

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

/* ── CSS VARIABLES ───────────────────────────────────────────── */
:root {
  /* Brand */
  --accent:         #F97316;
  --accent-dark:    #ea6c0a;
  --accent-light:   rgba(249,115,22,0.12);
  --accent-glow:    rgba(249,115,22,0.25);

  /* Backgrounds */
  --bg-base:        #0f1117;
  --bg-sidebar:     #13161e;
  --bg-panel:       #181c27;
  --bg-card:        #1e2235;
  --bg-card-hover:  #242840;
  --bg-input:       #1a1e2d;
  --bg-overlay:     rgba(0,0,0,0.6);

  /* Borders */
  --border:         #2a2f45;
  --border-light:   #333852;
  --border-focus:   #F97316;

  /* Text */
  --text-primary:   #f0f2f8;
  --text-secondary: #8b92ab;
  --text-muted:     #545975;
  --text-inverse:   #0f1117;

  /* Status Colors */
  --status-open:       #3b82f6;
  --status-waiting:    #f59e0b;
  --status-assigned:   #8b5cf6;
  --status-human:      #10b981;
  --status-ai:         #06b6d4;
  --status-escalated:  #ef4444;
  --status-resolved:   #22c55e;
  --status-closed:     #6b7280;

  /* Category Colors */
  --cat-admin:      #6366f1;
  --cat-sales:      #f59e0b;
  --cat-crm:        #10b981;
  --cat-operations: #3b82f6;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;

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

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow:0 0 20px rgba(249,115,22,0.15);

  /* Sidebar */
  --sidebar-width:     220px;
  --sidebar-collapsed: 64px;

  /* Topbar */
  --topbar-height: 60px;

  /* Transitions */
  --transition: 0.18s ease;
  --transition-slow: 0.3s ease;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-ar:   'Tajawal', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   11px;
  --text-sm:   12px;
  --text-base: 13.5px;
  --text-md:   14px;
  --text-lg:   16px;
  --text-xl:   18px;
  --text-2xl:  22px;
  --text-3xl:  28px;
}

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

html { height: 100%; }

body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }
input, textarea, select { font: inherit; }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }

/* ── APP SHELL ───────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width var(--transition-slow);
  position: relative;
  z-index: 100;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: var(--space-3); }
.sidebar.collapsed .sidebar-user { padding: var(--space-3); justify-content: center; }
.sidebar.collapsed .sidebar-user .icon-btn { display: none; }
.sidebar.collapsed .sidebar-brand {
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-2);
}
.sidebar.collapsed .sidebar-brand-left {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.sidebar.collapsed .brand-logo {
  width: 40px;
  height: 40px;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.brand-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  padding: 4px;
  box-sizing: border-box;
}
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-name {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.sidebar-toggle-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.sidebar-toggle-btn svg { width: 14px; height: 14px; }
.sidebar.collapsed .sidebar-toggle-btn svg { transform: rotate(180deg); }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-2) var(--space-1);
  margin-top: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-md);
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}
.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-label { flex: 1; }

.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  display: none;
}
.nav-badge.visible { display: block; }

/* Sidebar user */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
}
.sidebar-user:focus {
  outline: none;
}
.sidebar-user:focus-visible {
  box-shadow: inset 0 0 0 2px var(--border-light);
}
.sidebar-user #sidebar-logout-btn {
  cursor: pointer;
}

/* ── MAIN AREA ───────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  flex-shrink: 0;
  gap: var(--space-4);
}

.topbar-left { display: flex; align-items: center; gap: var(--space-3); }
.topbar-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: var(--space-3); }
.topbar-page-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2);
}
.topbar-page-actions[hidden] {
  display: none !important;
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search.is-route-hidden {
  display: none !important;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.topbar-search-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 14px 6px 34px;
  color: var(--text-primary);
  font-size: var(--text-sm);
  width: 240px;
  transition: border-color var(--transition), width var(--transition-slow);
  outline: none;
}
.topbar-search-input::placeholder { color: var(--text-muted); }
.topbar-search-input:focus {
  border-color: var(--accent);
  width: 300px;
}

/* ── PAGE CONTENT ────────────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── USER AVATAR ─────────────────────────────────────────────── */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), #e85d04);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  letter-spacing: 0.05em;
}
.user-avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.user-avatar.lg { width: 42px; height: 42px; font-size: 15px; }
.user-avatar.xl { width: 52px; height: 52px; font-size: 18px; }
.user-avatar[data-color="indigo"]   { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.user-avatar[data-color="amber"]    { background: linear-gradient(135deg, #f59e0b, #d97706); }
.user-avatar[data-color="emerald"]  { background: linear-gradient(135deg, #10b981, #059669); }
.user-avatar[data-color="blue"]     { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.user-avatar[data-color="purple"]   { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.user-avatar[data-color="rose"]     { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.user-avatar[data-color="cyan"]     { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.user-avatar[data-color="orange"]   { background: linear-gradient(135deg, #F97316, #ea6c0a); }

.user-avatar.has-photo {
  padding: 0;
  background: var(--bg-input);
  overflow: hidden;
}
.user-avatar.has-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.user-avatar.avatar-placeholder {
  background: linear-gradient(135deg, #3f3f46, #52525b);
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
  letter-spacing: 0;
}
.user-avatar.avatar-placeholder .avatar-placeholder-icon {
  width: 58%;
  height: 58%;
  flex-shrink: 0;
}

.user-avatar-wrap { position: relative; }
.user-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg-sidebar);
  position: absolute;
  bottom: 0;
  right: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  outline: none;
}
.btn:active { transform: scale(0.97); }

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

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

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-success {
  background: rgba(16,185,129,0.15);
  color: #34d399;
  border: 1px solid rgba(16,185,129,0.3);
}
.btn-success:hover { background: rgba(16,185,129,0.25); }

.btn-sm { padding: 5px 10px; font-size: var(--text-sm); }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: var(--radius-sm); }
.btn-icon { padding: 8px; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.icon-btn.active { background: var(--accent-light); color: var(--accent); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: opacity var(--transition);
}
.link-btn:hover { opacity: 0.8; }

/* ── BADGES / STATUS ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-open      { background: rgba(59,130,246,0.15);  color: #60a5fa; }
.badge-waiting   { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.badge-assigned  { background: rgba(139,92,246,0.15);  color: #a78bfa; }
.badge-human     { background: rgba(16,185,129,0.15);  color: #34d399; }
.badge-ai        { background: rgba(6,182,212,0.15);   color: #22d3ee; }
.badge-escalated { background: rgba(239,68,68,0.15);   color: #f87171; }
.badge-resolved  { background: rgba(34,197,94,0.15);   color: #4ade80; }
.badge-closed    { background: rgba(107,114,128,0.15); color: #9ca3af; }
.badge-ai-on     { background: rgba(6,182,212,0.15);   color: #22d3ee; }
.badge-human-on  { background: rgba(16,185,129,0.15);  color: #34d399; }
.badge-priority  { background: rgba(239,68,68,0.15);   color: #f87171; }

.badge-cat-admin      { background: rgba(99,102,241,0.15);  color: #a5b4fc; }
.badge-cat-sales      { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.badge-cat-crm        { background: rgba(16,185,129,0.15);  color: #34d399; }
.badge-cat-operations { background: rgba(59,130,246,0.15);  color: #60a5fa; }

/* ── TOGGLE SWITCH ───────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); }
.toggle input:checked ~ .toggle-label { color: var(--text-primary); }

/* ── FORM ELEMENTS ───────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.form-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); }
.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: var(--text-md);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--accent); }
.form-select option { background: var(--bg-card); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.card-title { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

/* ── DIVIDER ─────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }
.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 11px;
  color: var(--text-muted);
  margin: var(--space-4) 0;
}
.divider-label::before,
.divider-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── NOTIFICATIONS DROPDOWN ──────────────────────────────────── */
.notification-wrap { position: relative; }
.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 600;
}
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--bg-card-hover); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-content { flex: 1; min-width: 0; }
.notif-text { font-size: var(--text-sm); color: var(--text-primary); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: var(--space-6); text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* ── USER MENU DROPDOWN (avatar) — match topbar (.topbar) surface + gray border ─ */
.weps-user-menu {
  --weps-user-menu-caret-x: 50%;
  position: fixed;
  z-index: 350;
  min-width: 204px;
  width: max-content;
  max-width: min(228px, calc(100vw - 16px));
  padding: 7px 8px 7px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: none;
}

/* Caret toward trigger (JS sets --weps-user-menu-caret-x in px from menu left edge) */
.weps-user-menu::before {
  content: '';
  position: absolute;
  top: -5px;
  left: var(--weps-user-menu-caret-x);
  transform: translateX(-50%) rotate(45deg);
  width: 9px;
  height: 9px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  box-sizing: border-box;
  pointer-events: none;
}
.weps-user-menu.weps-user-menu--above::before {
  top: auto;
  bottom: -5px;
  transform: translateX(-50%) rotate(225deg);
}

.weps-user-menu-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 5px 6px;
}
.weps-user-menu-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.weps-user-menu-header-avatar.user-avatar {
  border-radius: var(--radius-full);
}
.weps-user-menu-header-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.weps-user-menu-header-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 168px;
}
.weps-user-menu-header-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 168px;
}

.weps-user-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.weps-user-menu-item:hover {
  background: var(--bg-card);
  border-color: var(--border-light);
}
.weps-user-menu-item:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--border-light);
}
.weps-user-menu-item:focus:not(:focus-visible) {
  box-shadow: none;
}
.weps-user-menu-item--danger {
  color: #e85d4a;
}
.weps-user-menu-item--danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}
.weps-user-menu-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.weps-user-menu-icon svg {
  width: 16px;
  height: 16px;
}
.weps-user-menu-item--danger .weps-user-menu-icon {
  color: #e85d4a;
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.06);
}
.weps-user-menu-label {
  flex: 1;
  min-width: 0;
}
.weps-user-menu-divider {
  height: 1px;
  margin: 6px 5px;
  background: var(--border);
}
.weps-user-menu-divider--header {
  margin: 2px 5px 6px;
}

.user-avatar {
  cursor: pointer;
}
.user-avatar:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--border);
}

/* ── TOAST ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  animation: toastIn 0.25s ease forwards;
  position: relative;
}
.toast.out { animation: toastOut 0.25s ease forwards; }
.toast-icon { width: 32px; height: 32px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-success .toast-icon { background: rgba(16,185,129,0.15); color: #34d399; }
.toast-error .toast-icon   { background: rgba(239,68,68,0.15);  color: #f87171; }
.toast-info .toast-icon    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.toast-warn .toast-icon    { background: rgba(245,158,11,0.15); color: #fbbf24; }
.toast-body { flex: 1; }
.toast-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.toast-msg   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toast-close { color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 2px; display: flex; align-items: center; }
.toast-close:hover { color: var(--text-primary); }
@keyframes toastIn  { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(20px); } }

/* ── MODAL ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn { from { opacity:0; transform:scale(0.92); } to { opacity:1; transform:scale(1); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  height: 60px;
  min-height: 60px;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: var(--text-lg); font-weight: 600; }
.modal-body { padding: var(--space-5) var(--space-6); overflow-y: auto; flex: 1; }

/* Staff add/edit — same profile “card” + inspire fields as Settings */
.modal-box.modal--staff-profile {
  max-width: min(900px, calc(100vw - 24px));
  width: 100%;
  max-height: min(92vh, 920px);
  border-radius: 20px;
  border-color: rgba(148, 163, 184, 0.2);
  background: linear-gradient(180deg, rgba(24, 28, 42, 0.98), rgba(15, 17, 23, 0.99));
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(148, 163, 184, 0.06) inset;
}
.modal-box.modal--staff-profile .modal-body {
  padding: var(--space-5) var(--space-6);
  background: transparent;
}
.staff-modal-profile-wrap.admin-page--settings {
  margin: 0;
  padding: 0;
}
.staff-modal-profile-wrap .settings-card.settings-card--profile {
  margin: 0;
  padding: var(--space-5);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: linear-gradient(180deg, rgba(30, 34, 53, 0.92), rgba(16, 19, 34, 0.92));
  box-shadow: none;
}
.staff-file-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
.modal-body strong {
  color: var(--accent-dark);
}
.modal-body p.form-hint {
  color: rgba(223, 224, 231, 1);
}
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}
.modal-footer--spread {
  justify-content: space-between;
}

/* ── Cannot delete department (categories) — layout inspired by warning dialog ── */
.modal-box.modal--dept-delete-warn {
  max-width: 480px;
  border-radius: var(--radius-lg);
}
.modal-box.modal--dept-delete-warn .modal-header {
  height: auto;
  min-height: 64px;
  padding: var(--space-4) var(--space-6);
  align-items: center;
}
.modal-box.modal--dept-delete-warn .modal-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.modal-box.modal--dept-delete-warn .modal-body {
  padding: var(--space-5) var(--space-6);
}
.modal-dept-delete-content {
  margin: 0;
}
.modal-dept-delete-name {
  font-weight: 700;
  color: var(--accent-dark);
}
.modal-dept-delete-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
}
.modal-dept-delete-notice-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: rgba(240, 242, 248, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-dept-delete-notice-icon svg {
  display: block;
}
.modal-dept-delete-notice-copy {
  min-width: 0;
  flex: 1;
}
.modal-dept-delete-notice-lead {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
  color: rgb(240, 242, 248);
}
.modal-dept-delete-notice-sub {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
}
.modal-footer.modal-footer--dept-delete-warn {
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Sign-out confirmation (sidebar-toned card; header row omitted; close in body) */
.modal-box.modal--signout #modal-header,
.modal-box.modal--signout .modal-header {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important;
  visibility: hidden;
  pointer-events: none;
}
.modal-box.modal--signout {
  max-width: 400px;
  width: calc(100% - 32px);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
.modal-box.modal--signout .modal-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-4) var(--space-6) var(--space-3);
  text-align: center;
  overflow: visible;
}
.modal-signout-confirm {
  box-sizing: border-box;
  width: 320px;
  max-width: 100%;
  margin: 0;
  padding-top: var(--space-1);
  align-self: center;
}
.modal-box.modal--signout .modal-footer.modal-footer--signout {
  padding: var(--space-3) var(--space-5) var(--space-5);
  border-top: none;
  gap: var(--space-3);
  justify-content: stretch;
  align-items: stretch;
}
.modal-signout-confirm__icon-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.modal-signout-exit-icon {
  display: block;
  color: var(--accent);
  flex-shrink: 0;
}
.modal-signout-exit-icon--sm {
  color: #fff;
}
.modal-signout-confirm__title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.modal-signout-confirm__text {
  margin: 0 auto;
  max-width: 300px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
  font-weight: 400;
}
.modal-signout-btn {
  flex: 1;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: opacity 0.15s ease, transform 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-signout-btn:active {
  transform: scale(0.98);
}
.modal-signout-btn--cancel {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.modal-signout-btn--cancel:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.modal-signout-btn--danger {
  background: var(--accent);
  color: #fff;
  border: none;
  gap: 8px;
}
.modal-signout-btn--danger:hover {
  background: var(--accent-dark);
}
.modal-signout-btn__row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ── DATA TABLE ──────────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

/* ── LOADING ─────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBARS ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  height: 100%;
  min-height: 200px;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-8);
}
.empty-state svg { opacity: 0.3; }
.empty-state h3 { font-size: var(--text-md); font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: var(--text-sm); max-width: 300px; line-height: 1.6; }

/* ── 404 — centered dark layout, subtle wave lines, accent pill button ─ */
.admin-page.weps-404-page {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-base);
}
.weps-404__bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.weps-404__waves-svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140%;
  min-width: 900px;
  height: auto;
  transform: translate(-50%, -50%);
  opacity: 1;
}
.weps-404__inner {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 520px;
  padding: var(--space-8) var(--space-6);
}
.weps-404__code {
  margin: 0 0 var(--space-3);
  font-size: clamp(4.5rem, 14vw, 7.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.06em;
  color: var(--text-primary);
}
.weps-404__title {
  margin: 0 0 var(--space-4);
  font-size: clamp(1.25rem, 3.5vw, 1.65rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}
.weps-404__text {
  margin: 0 auto var(--space-6);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 440px;
}
.weps-404__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 28px rgba(249, 115, 22, 0.35);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.weps-404__btn:hover {
  background: var(--accent-dark);
  box-shadow: 0 10px 32px rgba(249, 115, 22, 0.42);
}
.weps-404__btn:active {
  transform: scale(0.98);
}
.weps-404__btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 3px;
}
.weps-404__btn-icon {
  flex-shrink: 0;
}

/* ── MISC UTILITIES ──────────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.p-4 { padding: var(--space-4); }

/* ── MOBILE UTILS ────────────────────────────────────────────── */
.mobile-only { display: none; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
}

@media (max-width: 768px) {
  .mobile-only { display: flex; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--transition-slow), width var(--transition-slow);
    z-index: 500;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-search { display: none; }
}

/* ── DASHBOARD PAGE STATS ────────────────────────────────────── */
.dashboard-page {
  padding: var(--space-6);
  overflow-y: auto;
  height: 100%;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
}
.stat-card:hover::before { opacity: 1; }
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-value { font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: var(--text-sm); color: var(--text-muted); }
.stat-change { font-size: 11px; font-weight: 500; }
.stat-change.up   { color: #34d399; }
.stat-change.down { color: #f87171; }
