/* ========== CSS Variables - Dark Theme ========== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2234;
  --bg-card: #131a2b;
  --bg-hover: #1e2a43;
  
  --border: #1f2a44;
  --border-light: #2a3757;
  
  --text-primary: #e4e7f0;
  --text-secondary: #9ca3c0;
  --text-muted: #6b7390;
  
  --accent: #00d9a3;
  --accent-hover: #00f5b8;
  --accent-dim: #00d9a322;
  
  --purple: #a78bfa;
  --blue: #60a5fa;
  --orange: #fb923c;
  --pink: #f472b6;
  --red: #ef4444;
  --green: #10b981;
  --yellow: #fbbf24;
  
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(0, 217, 163, 0.15);
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef2f7;
  --bg-card: #ffffff;
  --bg-hover: #e9eef5;
  
  --border: #d6dce6;
  --border-light: #c5cdd8;
  
  --text-primary: #1a2234;
  --text-secondary: #4a5578;
  --text-muted: #6b7390;
  
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 50px 50px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 80%);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* ========== Typography ========== */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.mono { font-family: var(--font-mono); }

/* ========== Navbar ========== */
.navbar {
  position: sticky;
  top: 0;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

[data-theme="light"] .navbar {
  background: rgba(255, 255, 255, 0.85);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a0e1a;
  font-weight: 900;
  font-size: 18px;
}

.nav-brand-text .accent { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-link {
  padding: 8px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  background: var(--bg-hover);
  color: var(--accent);
}

.nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ========== Container ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  position: relative;
  z-index: 1;
}

.container-sm {
  max-width: 480px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0a0e1a;
  box-shadow: 0 4px 15px rgba(0, 217, 163, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 217, 163, 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}

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

.btn-danger:hover:not(:disabled) { background: #dc2626; }

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

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

.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-block { width: 100%; }

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  transition: border-color 0.2s;
}

.card:hover { border-color: var(--border-light); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  font-family: var(--font-mono);
  line-height: 1.5;
}

/* ========== Stats ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
}

.stat-card.purple::before { background: var(--purple); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.pink::before { background: var(--pink); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-beginner { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-intermediate { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.badge-advanced { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.badge-primary { background: var(--accent-dim); color: var(--accent); }
.badge-muted { background: var(--bg-tertiary); color: var(--text-secondary); }

/* Score badge */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
}

.score-high { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.score-mid { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.score-low { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* ========== Alerts ========== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }
.alert-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); color: #6ee7b7; }
.alert-info { background: rgba(96, 165, 250, 0.1); border: 1px solid rgba(96, 165, 250, 0.3); color: #93c5fd; }
.alert-warning { background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.3); color: #fcd34d; }

/* ========== Loader ========== */
.loader {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px;
}

.loader-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s;
}

.modal-large { max-width: 800px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title { font-size: 20px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ========== Tables ========== */
.table-wrapper {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg-tertiary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* ========== PWA Install Prompt ========== */
.install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  transition: transform 0.4s;
  max-width: calc(100vw - 40px);
}

.install-prompt.show { transform: translateX(-50%) translateY(0); }

.install-prompt-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0a0e1a;
}

.install-prompt-content { flex: 1; }
.install-prompt-title { font-size: 14px; font-weight: 700; }
.install-prompt-text { font-size: 12px; color: var(--text-secondary); }

/* ========== Mobile Menu ========== */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
}

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  
  .nav-links {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 30px solid var(--border);
    flex-direction: column;
    padding: 16px;
    gap: 4px;
    transform: translateY(-110%);
    transition: transform 0.3s;
  }
  
  .nav-links.open { transform: translateY(0); }
  
  .nav-link { padding: 12px 16px; }
  
  .container { padding: 20px 16px; }
  
  .card { padding: 18px; }
  
  .stats-grid { grid-template-columns: repeat(12, 1fr); gap: 12px; }
  
  .stat-value { font-size: 22px; }
  
  .table th, .table td { padding: 10px 12px; font-size: 13px; }
}

/* ========== Utility ========== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 28px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ========== Hero / Landing ========== */
.hero {
  padding: 80px 24px 60px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 20px;
}

.hero .gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ========== Code Block ========== */
.code-block {
  background: #0a0e1a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ========== Score Bar ========== */
.score-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.score-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.score-bar-track {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  border-radius: 4px;
  transition: width 0.6s;
}
