/* =========================================================
   SISTEMA DE DESIGN & VARIÁVEIS CSS - QUÍMICA SEM MISTÉRIO
   Estilo Premium, Vibrante, Acolhedor & Gamificado
   ========================================================= */

:root {
  /* Paleta Base - Dark Mode (Padrão) */
  --bg-primary: #0b0f19;
  --bg-secondary: #121826;
  --bg-card: rgba(26, 34, 52, 0.75);
  --bg-card-hover: rgba(36, 48, 74, 0.85);
  --bg-card-active: rgba(45, 60, 92, 0.95);
  --bg-glass: rgba(18, 24, 38, 0.65);
  
  /* Cores de Destaque & Gamificação */
  --primary: #6366f1;         /* Índigo vibrante */
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);

  --accent-cyan: #06b6d4;      /* Ciano Químico */
  --accent-cyan-glow: rgba(6, 182, 212, 0.35);

  --accent-emerald: #10b981;   /* Verde Sucesso / Acerto */
  --accent-emerald-light: #34d399;
  --accent-emerald-glow: rgba(16, 185, 129, 0.35);

  --accent-amber: #f59e0b;     /* Amarelo Estrela / Dica */
  --accent-amber-glow: rgba(245, 158, 11, 0.35);

  --accent-rose: #f43f5e;      /* Rosa / Atenção / Erro amigável */
  --accent-purple: #a855f7;    /* Roxo Magia / Teoria */

  /* Textos & Bordas */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  --border-card: rgba(255, 255, 255, 0.12);

  /* Sombras & Profundidade */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px var(--primary-glow);

  /* Dimensões & Raio */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --sidebar-width: 290px;
  --header-height: 72px;

  /* Fontes */
  --font-main: 'Outfit', sans-serif;
  --font-display: 'Fredoka', cursive, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Modo Claro / Light Theme */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --bg-card-active: #e2e8f0;
  --bg-glass: rgba(255, 255, 255, 0.75);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --border-card: rgba(0, 0, 0, 0.1);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   RESET & ESTILOS GLOBAIS
   ========================================================= */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Canvas para Confetes */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* Layout Principal */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* =========================================================
   BARRA LATERAL (SIDEBAR)
   ========================================================= */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 1.25rem;
  overflow-y: auto;
  gap: 1.25rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: var(--radius-full);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Seletor de Disciplina */
.subject-selector-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 0.75rem;
}

.custom-select-wrapper {
  position: relative;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
}

.subject-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--primary-light);
  pointer-events: none;
}

.subject-dropdown {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.4rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.subject-dropdown:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Navegação */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1px;
  padding: 0.5rem 0.75rem 0.2rem;
  margin-top: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(6, 182, 212, 0.08));
  color: #fff;
  border-color: var(--primary-glow);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.nav-item.active .nav-icon {
  color: var(--accent-cyan);
  transform: scale(1.1);
}

.nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-weight: 700;
}

.nav-badge.count {
  background: var(--primary);
  color: #fff;
  border: none;
}

.nav-tag {
  font-size: 0.65rem;
  padding: 0.18rem 0.5rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--primary));
  color: #fff;
  border-radius: var(--radius-full);
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Painel de Gamificação do Aluno */
.user-stats-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.user-avatar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 44px;
  height: 44px;
  background: var(--bg-primary);
  border: 2px solid var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 0 10px var(--primary-glow);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-level {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.user-xp-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.xp-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-emerald));
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-mini-row {
  display: flex;
  gap: 0.5rem;
}

.stat-pill {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* =========================================================
   CONTEÚDO PRINCIPAL & NAVBAR SUPERIOR
   ========================================================= */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
}

.top-navbar {
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.current-module-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.crumb-subject {
  color: var(--accent-cyan);
}

.crumb-sep {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.crumb-chapter {
  color: var(--text-primary);
  font-weight: 700;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Botões do Topo */
.action-pill-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-pill-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.action-pill-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 12px var(--primary-glow);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--primary-light);
  transform: scale(1.05);
}

/* Corpo do Conteúdo */
.content-body {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* =========================================================
   UTILITÁRIOS GERAIS DE TEXTO & CORES
   ========================================================= */

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-md { font-size: 1rem; }
.text-lg { font-size: 1.25rem; }
.text-xl { font-size: 1.5rem; }
.text-2xl { font-size: 2rem; }

.font-bold { font-weight: 700; }
.font-extra { font-weight: 800; }
.uppercase { text-transform: uppercase; }

.text-primary { color: var(--primary-light); }
.text-cyan { color: var(--accent-cyan); }
.text-emerald { color: var(--accent-emerald); }
.text-amber { color: var(--accent-amber); }
.text-rose { color: var(--accent-rose); }
.text-purple { color: var(--accent-purple); }
.text-muted { color: var(--text-muted); }
.text-orange { color: #f97316; }
.text-yellow { color: #eab308; }

.hidden { display: none !important; }
.mobile-only { display: none; }

/* =========================================================
   RESPONSIVIDADE
   ========================================================= */

@media (max-width: 992px) {
  :root {
    --sidebar-width: 270px;
  }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-only {
    display: flex;
  }
  .top-navbar {
    padding: 0 1.25rem;
  }
  .content-body {
    padding: 1.25rem;
  }
  .action-pill-btn .btn-text {
    display: none;
  }
}
