/* ═══════════════════════════════════════════════════════════
   MAIN.CSS — EstudaAI
   Estilos principais da aplicação
   ═══════════════════════════════════════════════════════════ */

/* ── VARIÁVEIS PADRÃO (tema escuro) ─────────────────────── */
:root {
  --bg: #0d0f1a;
  --surface: #141728;
  --surface2: #1c2035;
  --border: #2a2f4a;
  --accent: #4f8aff;
  --accent2: #a78bfa;
  --accent3: #34d399;
  --gold: #f59e0b;
  --danger: #f87171;
  --text: #e8ecff;
  --text-dim: #8892b0;
  --text-muted: #4a5178;
  --radius: 16px;
  --radius-sm: 10px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── FUNDO AMBIENTADO ────────────────────────────────────── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(
      ellipse 80% 60% at 10% 0%,
      rgba(79, 138, 255, 0.1) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 50% at 90% 100%,
      rgba(167, 139, 250, 0.08) 0%,
      transparent 60%
    );
  pointer-events: none;
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── FOCUS ───────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT
════════════════════════════════════════════════════════════ */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh; /* celular: descontra a barra de endereço do navegador */
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════════════ */
#sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 8px;
  position: relative;
  /* Se o conteúdo for mais alto que a tela (zoom 100% em notebook), a
     sidebar rola em vez de cortar — e o "Sair" fica sempre visível
     (ver .sidebar-user em auth.css, que é sticky no rodapé). */
  overflow-x: hidden;
  overflow-y: auto;
}

#sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #1c0800, #3d1200);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  overflow: hidden;
  box-shadow: 0 0 16px rgba(220, 80, 0, 0.45);
}

.logo-text {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}

.logo-text span {
  color: var(--accent);
}

/* Nav label */
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

/* Nav buttons */
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.18s;
  width: 100%;
  text-align: left;
}

.nav-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-btn.active {
  background: rgba(79, 138, 255, 0.12);
  color: var(--accent);
}
.nav-btn .icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* Streak widget */
.streak-widget {
  margin-top: auto;
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.12),
    rgba(239, 68, 68, 0.08)
  );
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.streak-widget:hover {
  transform: translateY(-2px);
}

.streak-fire {
  font-size: 36px;
  display: block;
  animation: flicker 1.4s ease-in-out infinite alternate;
}

@keyframes flicker {
  0% {
    text-shadow:
      0 0 8px #f59e0b,
      0 0 20px #f97316;
    transform: scale(1);
  }
  100% {
    text-shadow:
      0 0 16px #fbbf24,
      0 0 35px #f59e0b;
    transform: scale(1.1);
  }
}

.streak-count {
  font-family: "Syne", sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--gold);
}

.streak-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ════════════════════════════════════════════════════════════
   ÁREA PRINCIPAL
════════════════════════════════════════════════════════════ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════════
   BARRA DE ABAS
════════════════════════════════════════════════════════════ */
#tab-bar {
  display: flex;
  gap: 4px;
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tab {
  padding: 10px 20px;
  border-radius: 10px 10px 0 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.18s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--surface);
  margin-bottom: -1px;
}

/* ════════════════════════════════════════════════════════════
   PAINÉIS
════════════════════════════════════════════════════════════ */
.panel {
  display: none;
  flex: 1;
  overflow: hidden;
}
.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ════════════════════════════════════════════════════════════
   CONFETE
════════════════════════════════════════════════════════════ */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  z-index: 9999;
  pointer-events: none;
  animation: confettiFall 2.5s forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-40px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ════════════════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9998;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
}

#toast.show {
  transform: none;
  opacity: 1;
}

.toast-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.toast-text {
  font-size: 14px;
  line-height: 1.4;
}
.toast-title {
  font-weight: 700;
  color: var(--text);
}
.toast-sub {
  color: var(--text-dim);
  font-size: 12.5px;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVO
════════════════════════════════════════════════════════════ */

/* Telas baixas (notebooks a 100% de zoom): compacta a sidebar pra
   caber tudo sem precisar rolar. */
@media (max-height: 820px) {
  #sidebar {
    padding: 14px 12px;
    gap: 4px;
  }
  .logo {
    padding: 4px 10px 12px;
    margin-bottom: 4px;
  }
  .nav-btn {
    padding: 8px 12px;
  }
  .streak-widget {
    padding: 8px;
  }
  .streak-widget svg {
    width: 34px;
    height: 43px;
  }
}
@media (max-width: 768px) {
  #sidebar {
    display: none;
  }
  #tab-bar {
    padding: 12px 12px 0;
  }
  .stats-row {
    grid-template-columns: 1fr 1fr;
  }
  #messages {
    padding: 14px;
  }
  #input-area {
    padding: 12px;
  }
}
