/* ================== GLOBAL LAYOUT FIX ================== */
* {
  min-width: 0;
}

/* ================== CSS VARIABLES ================== */
:root {
  --bg-primary: #0a0e14;
  --bg-secondary: #111820;
  --bg-tertiary: #1a2330;
  --bg-elevated: #232d3d;
  --border-color: #2a3548;
  --border-light: #3a4a63;
  
  --text-primary: #f0f4f8;
  --text-secondary: #8b9aae;
  --text-muted: #5a6a7d;
  
  --accent-primary: #3b82f6;
  --accent-secondary: #60a5fa;
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  
  --online: #22c55e;
  --offline: #ef4444;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  
  /* ================== Z-INDEX HIERARCHY ================== */
  --z-base: 1;
  --z-dropdown: 10;
  --z-pagination: 20;
  --z-header: 50;
  --z-sidebar-overlay: 60;
  --z-sidebar: 70;
  --z-bottom-bar: 80;
  --z-floating-widget: 90;
  --z-modal: 500; /* Modal root - must be above all page content */
  --z-toast: 600; /* Toasts above modal */
  
  /* ================== LAYOUT DIMENSIONS ================== */
  --header-height: 56px;
  --sidebar-width: 260px;
  --bottom-bar-height: 72px;
  --pagination-height: 64px;
  --stats-bar-height: 80px;
}

/* ================== THEMES ================== */
/* default = Ocean Blue (built into :root above) */

[data-theme="purple"] {
  --bg-primary:    #0d0a14;
  --bg-secondary:  #150f22;
  --bg-tertiary:   #1e1530;
  --bg-elevated:   #2a1f42;
  --border-color:  #3a2a5a;
  --border-light:  #4e3a78;
  --accent-primary:   #8b5cf6;
  --accent-secondary: #a78bfa;
}

[data-theme="emerald"] {
  --bg-primary:    #090f0d;
  --bg-secondary:  #0f1a16;
  --bg-tertiary:   #162420;
  --bg-elevated:   #1f332c;
  --border-color:  #264436;
  --border-light:  #30594a;
  --accent-primary:   #10b981;
  --accent-secondary: #34d399;
}

[data-theme="crimson"] {
  --bg-primary:    #120808;
  --bg-secondary:  #1c0d0d;
  --bg-tertiary:   #261414;
  --bg-elevated:   #321c1c;
  --border-color:  #4a2222;
  --border-light:  #6b3030;
  --accent-primary:   #ef4444;
  --accent-secondary: #f87171;
}

[data-theme="amber"] {
  --bg-primary:    #110e06;
  --bg-secondary:  #1a150a;
  --bg-tertiary:   #241d10;
  --bg-elevated:   #302618;
  --border-color:  #4a3a1a;
  --border-light:  #6b5522;
  --accent-primary:   #f59e0b;
  --accent-secondary: #fbbf24;
}

[data-theme="rose"] {
  --bg-primary:    #120810;
  --bg-secondary:  #1c0d18;
  --bg-tertiary:   #261422;
  --bg-elevated:   #321c2e;
  --border-color:  #4a2244;
  --border-light:  #6b305e;
  --accent-primary:   #f43f5e;
  --accent-secondary: #fb7185;
}

[data-theme="cyan"] {
  --bg-primary:    #060f12;
  --bg-secondary:  #0a171d;
  --bg-tertiary:   #102028;
  --bg-elevated:   #162c36;
  --border-color:  #1e404e;
  --border-light:  #2a5a6e;
  --accent-primary:   #06b6d4;
  --accent-secondary: #22d3ee;
}

[data-theme="slate"] {
  --accent-primary:   #94a3b8;
  --accent-secondary: #cbd5e1;
}

/* ================== THEME SWATCHES ================== */
.theme-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  outline: none;
  flex-shrink: 0;
}
.theme-swatch:hover { transform: scale(1.18); }
.theme-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
  transform: scale(1.12);
}

/* ================== RESET & BASE ================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior: none;
}

/* ================== ICONS ================== */
.icon-xs { width: 14px; height: 14px; stroke-width: 2; }
.icon-sm { width: 18px; height: 18px; stroke-width: 2; }
.icon-md { width: 22px; height: 22px; stroke-width: 2; }
.icon-lg { width: 28px; height: 28px; stroke-width: 2; }

/* ================== AUTH SCREEN ================== */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.auth-container {
  width: 100%;
  max-width: 360px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo-icon {
  width: 56px;
  height: 56px;
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}

.auth-form h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.input-group input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 44px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  transition: transform, opacity, background-color, background, border-color, box-shadow 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

.input-group input[type="password"] {
  padding-right: 44px;
}

.toggle-password {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-primary, .btn-secondary {
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform, opacity, background-color, background, border-color, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
}

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

.btn-primary:active {
  transform: scale(0.98);
  background: #2563eb;
}

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

.btn-secondary:active {
  background: var(--bg-elevated);
  transform: scale(0.98);
}

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

.btn-danger:disabled {
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-danger:not(:disabled):active {
  transform: scale(0.98);
  background: #dc2626;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
}

.btn-loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auth-error, .form-error {
  color: var(--accent-danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

.auth-footer {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 4px;
}
