/* ============================================================
   ESS Portal — Theme Definitions
   Applied via data-theme attribute on <html> element
   ============================================================ */

/* ── Theme 1: Blue (Default) ────────────────────────────────── */
[data-theme="blue"],
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #eff6ff;
  --primary-rgb:    37, 99, 235;
  --sidebar-bg:     #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-active-bg:    #eff6ff;
  --sidebar-active-color: #2563eb;
  --sidebar-active-border:#2563eb;
  --sidebar-hover-bg:     #eff6ff;
  --sidebar-text:   #64748b;
  --topbar-bg:      #ffffff;
  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text-primary:   #1e293b;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --brand-bg:       #2563eb;
  --sf-theme-url:   'https://cdn.syncfusion.com/ej2/29.1.33/material3.css';
}

/* ── Theme 2: Purple ─────────────────────────────────────────── */
[data-theme="purple"] {
  --primary:        #7c3aed;
  --primary-dark:   #6d28d9;
  --primary-light:  #f5f3ff;
  --primary-rgb:    124, 58, 237;
  --sidebar-bg:     #1e1b4b;
  --sidebar-border: #312e81;
  --sidebar-active-bg:    #312e81;
  --sidebar-active-color: #c4b5fd;
  --sidebar-active-border:#a78bfa;
  --sidebar-hover-bg:     #312e81;
  --sidebar-text:   #a5b4fc;
  --topbar-bg:      #ffffff;
  --bg:             #f5f3ff;
  --surface:        #ffffff;
  --border:         #e9d5ff;
  --text-primary:   #1e1b4b;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --brand-bg:       #7c3aed;
}

/* ── Theme 3: Green (Emerald) ────────────────────────────────── */
[data-theme="green"] {
  --primary:        #059669;
  --primary-dark:   #047857;
  --primary-light:  #ecfdf5;
  --primary-rgb:    5, 150, 105;
  --sidebar-bg:     #064e3b;
  --sidebar-border: #065f46;
  --sidebar-active-bg:    #065f46;
  --sidebar-active-color: #6ee7b7;
  --sidebar-active-border:#34d399;
  --sidebar-hover-bg:     #065f46;
  --sidebar-text:   #6ee7b7;
  --topbar-bg:      #ffffff;
  --bg:             #f0fdf4;
  --surface:        #ffffff;
  --border:         #bbf7d0;
  --text-primary:   #064e3b;
  --text-secondary: #374151;
  --text-muted:     #6b7280;
  --brand-bg:       #059669;
}

/* ── Theme 4: Dark ───────────────────────────────────────────── */
[data-theme="dark"] {
  --primary:        #3b82f6;
  --primary-dark:   #2563eb;
  --primary-light:  #1e3a5f;
  --primary-rgb:    59, 130, 246;
  --sidebar-bg:     #0f172a;
  --sidebar-border: #1e293b;
  --sidebar-active-bg:    #1e293b;
  --sidebar-active-color: #93c5fd;
  --sidebar-active-border:#3b82f6;
  --sidebar-hover-bg:     #1e293b;
  --sidebar-text:   #94a3b8;
  --topbar-bg:      #1e293b;
  --bg:             #0f172a;
  --surface:        #1e293b;
  --border:         #334155;
  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:     #64748b;
  --brand-bg:       #1e40af;
}

/* ── Theme 5: Slate (Corporate) ─────────────────────────────── */
[data-theme="slate"] {
  --primary:        #475569;
  --primary-dark:   #334155;
  --primary-light:  #f1f5f9;
  --primary-rgb:    71, 85, 105;
  --sidebar-bg:     #1e293b;
  --sidebar-border: #334155;
  --sidebar-active-bg:    #334155;
  --sidebar-active-color: #e2e8f0;
  --sidebar-active-border:#94a3b8;
  --sidebar-hover-bg:     #334155;
  --sidebar-text:   #94a3b8;
  --topbar-bg:      #ffffff;
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --brand-bg:       #1e293b;
}

/* ── Theme 6: Rose ───────────────────────────────────────────── */
[data-theme="rose"] {
  --primary:        #e11d48;
  --primary-dark:   #be123c;
  --primary-light:  #fff1f2;
  --primary-rgb:    225, 29, 72;
  --sidebar-bg:     #4c0519;
  --sidebar-border: #881337;
  --sidebar-active-bg:    #881337;
  --sidebar-active-color: #fda4af;
  --sidebar-active-border:#fb7185;
  --sidebar-hover-bg:     #881337;
  --sidebar-text:   #fda4af;
  --topbar-bg:      #ffffff;
  --bg:             #fff1f2;
  --surface:        #ffffff;
  --border:         #fecdd3;
  --text-primary:   #4c0519;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --brand-bg:       #e11d48;
}

/* ============================================================
   Theme-aware overrides
   ============================================================ */

/* Sidebar uses theme variables */
.ess-sidebar {
  background: var(--sidebar-bg) !important;
  border-right-color: var(--sidebar-border) !important;
}
.sidebar-brand {
  border-bottom-color: var(--sidebar-border) !important;
}
.brand-icon {
  background: var(--brand-bg) !important;
}
.brand-name {
  color: var(--sidebar-active-color, var(--text-primary)) !important;
}
.brand-tagline {
  color: var(--sidebar-text) !important;
  opacity: 0.7;
}
.sidebar-employee {
  background: var(--sidebar-active-bg) !important;
  border-bottom-color: var(--sidebar-border) !important;
}
.emp-name {
  color: var(--sidebar-active-color, var(--text-primary)) !important;
}
.emp-code {
  color: var(--sidebar-text) !important;
}
.emp-avatar {
  background: var(--primary) !important;
}
.nav-section-label {
  color: var(--sidebar-text) !important;
  opacity: 0.6;
}
.sidebar-nav li a {
  color: var(--sidebar-text) !important;
}
.sidebar-nav li a:hover {
  background: var(--sidebar-hover-bg) !important;
  color: var(--sidebar-active-color, var(--primary)) !important;
}
.sidebar-nav li.active a {
  background: var(--sidebar-active-bg) !important;
  color: var(--sidebar-active-color, var(--primary)) !important;
  border-right-color: var(--sidebar-active-border) !important;
}
.sidebar-footer {
  border-top-color: var(--sidebar-border) !important;
}
.logout-btn {
  color: var(--sidebar-text) !important;
  opacity: 0.7;
}
.logout-btn:hover {
  background: rgba(255,255,255,0.1) !important;
  opacity: 1;
}

/* Topbar */
.ess-topbar {
  background: var(--topbar-bg) !important;
  border-bottom-color: var(--border) !important;
}

/* Dark theme: invert text colors where needed */
[data-theme="dark"] .page-title,
[data-theme="dark"] .topbar-date { color: var(--text-primary) !important; }
[data-theme="dark"] .card-panel   { background: var(--surface) !important; border-color: var(--border) !important; }
[data-theme="dark"] .stat-card    { background: var(--surface) !important; border-color: var(--border) !important; }
[data-theme="dark"] .panel-header { border-bottom-color: var(--border) !important; }
[data-theme="dark"] .ess-input    { background: #0f172a !important; border-color: var(--border) !important; color: var(--text-primary) !important; }
[data-theme="dark"] .modal-box    { background: var(--surface) !important; }
[data-theme="dark"] .modal-header { border-bottom-color: var(--border) !important; }
[data-theme="dark"] .ess-alert-success { background: #064e3b; border-color: #065f46; color: #6ee7b7; }
[data-theme="dark"] .ess-alert-error   { background: #450a0a; border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .notif-panel  { background: var(--surface) !important; border-color: var(--border) !important; }
[data-theme="dark"] .notif-item   { border-bottom-color: var(--border) !important; }
[data-theme="dark"] .balance-card { background: var(--surface) !important; border-color: var(--border) !important; }
[data-theme="dark"] .balance-header { color: var(--text-secondary) !important; }

/* Theme Switcher UI */
.theme-switcher-wrapper { position: relative; }
.theme-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: none; border: 1px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 16px;
  transition: var(--transition);
}
.theme-btn:hover { background: var(--bg); }
.theme-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 16px; width: 220px; z-index: 200;
}
.theme-panel-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 12px;
}
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
  transition: var(--transition); border: 2px solid transparent;
}
.theme-option:hover { background: var(--bg); }
.theme-option.active { border-color: var(--primary); background: var(--primary-light); }
.theme-swatch {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  position: relative; overflow: hidden;
}
.theme-swatch::after {
  content: ''; position: absolute; right: 0; top: 0;
  width: 50%; height: 100%;
  background: rgba(255,255,255,0.25);
}
.theme-option.active .theme-swatch::before {
  content: '✓';
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 700; z-index: 1;
}
.theme-label {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  text-align: center;
}

/* ── Mobile: dropdowns open upward so they don't hide behind bottom nav ── */
@media (max-width: 768px) {
  .notif-panel {
    bottom: calc(100% + 8px);
    top: auto;
  }
  .theme-panel {
    bottom: calc(100% + 8px);
    top: auto;
  }
}
