:root {
  --bg-color: #f3f4f6;
  --panel-bg: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --sidebar-bg: #2B2D42;
  --sidebar-text: #e2e8f0;
  --sidebar-active: #7C3AED;
  --accent: #7C3AED;
  --accent-hover: #6D28D9;
  --correct: #10b981;
  --incorrect: #ef4444;
  --border-color: #e5e7eb;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --sidebar-w: 250px;
}

[data-theme="dark"] {
  --bg-color: #0f172a;
  --panel-bg: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-active: #7C3AED;
  --border-color: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4 { font-weight: 600; margin-top: 0; }
a { color: var(--accent); text-decoration: none; }

/* ========== Layout ========== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  z-index: 100;
  transition: background-color 0.3s, transform 0.3s;
}

.sidebar-header {
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  margin-bottom: 2rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
}

.nav-icon {
  font-size: 1.25rem;
  margin-right: 10px;
  opacity: 0.8;
  vertical-align: middle;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.7rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  border-radius: 8px;
  margin-bottom: 0.35rem;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: white;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2rem 2.5rem;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Mobile header — hidden on desktop */
.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* ========== Common UI ========== */

.card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all 0.3s;
  overflow: hidden;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn-outline:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Badges */
.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: bold;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--correct); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

/* ========== Forms ========== */

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  box-sizing: border-box;
  font-size: 1rem;
}

.auth-container {
  max-width: 420px;
  margin: 10vh auto;
  padding: 2.5rem 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.alert-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--incorrect);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

/* ========== Quiz ========== */

.option-label {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  background: var(--panel-bg);
  transition: all 0.2s;
  margin-bottom: 0.6rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  word-break: break-word;
}

.option-label:hover { border-color: var(--accent); }
.option-label input { display: none; }

.option-label.correct {
  border-color: var(--correct) !important;
  background: rgba(16, 185, 129, 0.05) !important;
  color: var(--correct);
  font-weight: 500;
}

.option-label.incorrect {
  border-color: var(--incorrect) !important;
  background: rgba(239, 68, 68, 0.05) !important;
  color: var(--incorrect);
  font-weight: 500;
}

/* Glass card for quiz */
.glass {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

/* ========== Dashboard / Categories layouts ========== */

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.category-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.category-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ========== Responsive ========== */

@media (max-width: 1024px) {
  .main-content {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 0;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.1rem;
  }

  .burger-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
  }

  .burger-btn .material-symbols-rounded {
    font-size: 1.75rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .category-card {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .category-actions {
    justify-content: stretch;
  }

  .category-actions .btn {
    flex: 1;
  }

  .glass {
    padding: 1.25rem;
  }

  h2 {
    font-size: 1.4rem !important;
  }
}
