/* === COMMON STYLES: Variables, Shared Components === */
/* Premium Dark Theme (default) */
:root,
[data-theme="dark"] {
  /* Core neutral dark */
  --bg: #0B0D10;
  --bg-root: #0B0D10;

  --surface-0: #0F1115;
  --surface-1: #14171C;
  --surface-2: #1A1E24;
  --surface-3: #222731;

  --sidebar-bg: #0E1116;
  --topbar-bg: #101318;
  --card: #14171C;
  --card2: #1A1E24;

  --border: rgba(229, 231, 235, 0.08);
  --border-soft: rgba(229, 231, 235, 0.06);
  --border-strong: rgba(229, 231, 235, 0.14);

  --text: #E7EAF0;
  --text-primary: #F3F4F6;
  --text-secondary: #A7AFBA;
  --muted: #747D89;
  --disabled: #515A66;

  /* Neutral accent, not purple */
  --accent: #D6D9DF;
  --accent-soft: rgba(229, 231, 235, 0.10);
  --accent-hover: rgba(229, 231, 235, 0.14);
  --accent-border: rgba(229, 231, 235, 0.18);

  /* Optional warm primary for important CTA only */
  --primary: #EAB308;
  --primary-hover: #FACC15;
  --primary-soft: rgba(234, 179, 8, 0.12);

  /* Semantic colors */
  --good: #22C55E;
  --warn: #F59E0B;
  --danger: #EF4444;
  --blue: #3B82F6;
  --yellow: #EAB308;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Sidebar layout color compatibility mappings */
  --sidebar-surface: var(--surface-0);
  --sidebar-surface-hover: var(--surface-1);
  --sidebar-active: var(--accent-soft);
  --sidebar-active-border: var(--accent-border);
  --sidebar-active-text: var(--text-primary);

  /* Legacy variable mappings to maintain compatibility */
  --line: var(--border);
  --radius: var(--radius-md);
  --purple: var(--accent);
  --accent-2: var(--accent);
}

/* [data-theme="light"] light theme removed to enforce dark SaaS dashboard */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* === ANIMATIONS === */
@keyframes listFadeIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
.list-animate { animation: listFadeIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

body { transition: background .3s, color .3s; }

/* Avatar Dropdown */
.avatar-dropdown { position: relative; }
.avatar-btn { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 14px; }
.avatar-btn:hover { background: var(--card); }
.avatar-icon { font-size: 18px; }
.avatar-icon-lg { font-size: 28px; }
.avatar-arrow { font-size: 10px; color: var(--muted); }
.avatar-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 260px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.5); z-index: 1000; padding: 8px 0; }
.avatar-menu.show { display: block; }
.menu-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.menu-header span:last-child { font-size: 12px; color: var(--muted); word-break: break-all; }
.menu-divider { height: 1px; background: var(--line); margin: 8px 0; }
.menu-section { padding: 8px 16px; }
.menu-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.menu-section select, .menu-section input { width: 100%; padding: 8px 10px; background: var(--card2); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 12px; }
.threshold-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.threshold-row input { width: 60px !important; padding: 6px 8px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; background: none; border: none; color: var(--text); font-size: 13px; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--card2); }
.menu-item.danger { color: var(--danger); }

/* Settings group (addUserInfo) */
.settings-group { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.settings-group select, .settings-group input { background: transparent; border: none; color: var(--text); font-size: 12px; outline: none; }
.settings-group input { width: 70px; }

/* Section title used in stats modals */
.section-title { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 12px; margin-top: 16px; text-transform: uppercase; letter-spacing: 1px; }

/* Sync Error */
.sync-error-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 10000; justify-content: center; align-items: center; backdrop-filter: blur(6px); }
.sync-error-overlay.show { display: flex; }
.sync-error-box { background: var(--card); border: 2px solid var(--danger); border-radius: 20px; padding: 40px; max-width: 480px; width: 90%; text-align: center; animation: syncErrorShake 0.5s ease-in-out; box-shadow: 0 0 60px rgba(239,68,68,0.3); }
.sync-error-box .error-icon { font-size: 64px; margin-bottom: 16px; display: block; animation: syncErrorPulse 2s infinite; }
.sync-error-box h2 { color: var(--danger); font-size: 22px; margin-bottom: 12px; }
.sync-error-box p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }
.sync-error-box p strong { color: var(--danger); }
.sync-error-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.sync-error-actions .btn { padding: 12px 24px; font-size: 14px; font-weight: 700; border-radius: 12px; }
.sync-error-actions .btn.retry { background: var(--danger); color: white; border: none; }
.sync-error-actions .btn.retry:hover { filter: brightness(1.15); }
.sync-error-actions .btn.dismiss { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.sync-error-banner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 9999; background: linear-gradient(90deg,#dc2626,#b91c1c); color: white; padding: 10px 20px; text-align: center; font-size: 13px; font-weight: 600; cursor: pointer; animation: syncBannerPulse 3s infinite; }
.sync-error-banner.show { display: flex; align-items: center; justify-content: center; gap: 10px; }

@keyframes syncErrorShake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-10px)} 40%{transform:translateX(10px)} 60%{transform:translateX(-6px)} 80%{transform:translateX(6px)} }
@keyframes syncErrorPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }
@keyframes syncBannerPulse { 0%,100%{opacity:1} 50%{opacity:0.85} }
@keyframes pulse-dup { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* === RIGHT DRAWERS === */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
.drawer-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-left: 1px solid var(--line);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}
.drawer.show {
  transform: translateX(0);
}
.drawer-header {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.drawer-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.drawer-footer {
  padding: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

