/* ==========================================================================
   1. RESET & VARIÁVEIS GERAIS
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0d0f14;
  --bg2: #161920;
  --bg3: #1e2229;
  --border: #2a2e38;
  --text: #f0f2f7;
  --text2: #8b90a0;
  --text3: #555c6e;
  --accent: #6c63ff;
  --accent-hover: #7c74ff;
  --accent-soft: rgba(108, 99, 255, 0.12);
  --danger: #ff4757;
  --success: #2ed573;
  --warning: #ffa502;

  --sidebar-w: 280px;
  --topbar-h: 65px;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0,0,0,0.5);

  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Cores de Matérias */
  --c1: #6c63ff; --c2: #ff6584; --c3: #38ef7d; --c4: #ff9f43; --c5: #00d2ff;
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
}

a { color: inherit; text-decoration: none; }

.page-content {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.greeting-kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  font-weight: 900;
  color: rgba(108, 99, 255, 0.95);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.greeting-title {
  font-family: var(--font-head);
  font-size: clamp(30px, 6vw, 44px);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}

.dashboard-hero {
  padding: 4px 0 6px;
}

.dashboard-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 12px 0 20px;
}

.widget {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
}

.widget h3 {
  font-family: var(--font-head);
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 10px;
}

.section-block {
  margin-top: 18px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-header h3 {
  font-family: var(--font-head);
  font-size: 18px;
  letter-spacing: -0.01em;
}

.text-btn {
  color: rgba(108, 99, 255, 0.95);
  font-weight: 800;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 10px;
}

.text-btn:hover {
  background: rgba(108,99,255,0.10);
}

.list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 22px 18px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  opacity: 0.35;
  color: rgba(240,242,247,0.75);
}

.empty-state p {
  color: var(--text2);
  font-weight: 700;
}

.empty-state button {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(108,99,255,0.55);
  background: rgba(108,99,255,0.08);
  color: rgba(210, 208, 255, 0.98);
  font-weight: 900;
  cursor: pointer;
}

.empty-state button:hover {
  background: rgba(108,99,255,0.13);
  border-color: rgba(108,99,255,0.75);
}

/* ==========================================================================
   MODAL / OVERLAY / TOAST
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(6px);
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: min(520px, 100%);
  max-height: min(78vh, 720px);
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(22,25,32,0.92);
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.modal-header h3 {
  font-family: var(--font-head);
  font-size: 16px;
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 14px;
  overflow: auto;
  max-height: calc(78vh - 54px);
}

.form-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-select,
.form-textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
}

.form-textarea {
  resize: vertical;
}

.form-select:focus,
.form-textarea:focus {
  border-color: rgba(108,99,255,0.85);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(22,25,32,0.92);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: 0 16px 44px rgba(0,0,0,0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9000;
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   2. TELA DE CARREGAMENTO (SPLASH)
   ========================================================================== */
.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.splash-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner {
  width: 45px;
  height: 45px;
  border: 4px solid var(--accent-soft);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

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

/* ==========================================================================
   3. AUTENTICAÇÃO (O QUE ESTAVA "BUGADO")
   ========================================================================== */
#auth-screen {
  min-height: 100vh;
  width: 100vw;
  display: flex; /* CRUCIAL: Ativa o alinhamento */
  align-items: center; /* Centraliza verticalmente */
  justify-content: center; /* Centraliza horizontalmente */
  padding: 20px;
  background: radial-gradient(circle at top right, #1a1c2c, var(--bg));
  position: fixed;
  top: 0;
  left: 0;
  z-index: 5000;
}

.auth-container {
  background: var(--bg2);
  width: 100%;
  max-width: 400px;
  padding: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-header h1 {
  font-family: var(--font-head);
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 5px;
  letter-spacing: -1px;
}

.auth-header p {
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 30px;
}

.auth-tabs {
  display: flex;
  background: var(--bg3);
  padding: 5px;
  border-radius: 12px;
  margin-bottom: 25px;
  gap: 5px;
}

.auth-tabs button {
  flex: 1;
  padding: 10px;
  background: transparent;
  color: var(--text2);
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.3s;
}

.auth-tabs button.active {
  background: var(--accent);
  color: white;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  text-align: left;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
}

.form-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: white;
  padding: 15px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 10px;
  transition: 0.3s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* ==========================================================================
   4. LAYOUT DO APP PRINCIPAL (SIDEBAR & CONTEÚDO)
   ========================================================================== */
#main-app {
  display: flex;
  height: 100vh;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 900;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 1000;
}

.sidebar-header {
  padding: 25px;
  border-bottom: 1px solid var(--border);
}

.close-sidebar {
  margin-left: auto;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.user-info .user-name {
  font-weight: 700;
  color: var(--text);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn-small {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg3);
}

.icon-btn-small:hover {
  color: var(--text);
  border-color: var(--text3);
}

.sidebar-nav {
  padding: 10px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  width: 100%;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text2);
  cursor: pointer;
  font-weight: 700;
  border-radius: 12px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
}

.nav-item.active, .nav-item:hover {
  color: white;
  background: var(--accent-soft);
  border-color: rgba(255,255,255,0.06);
}

.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 14px;
  flex: 0 0 auto;
}

.sidebar-section {
  padding: 14px 14px 10px;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--text2);
  margin-bottom: 10px;
}

.subjects-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.subject-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text2);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.04);
}

.subject-item:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text);
}

.subject-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.subject-name { font-weight: 700; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sync-status-container {
  display: flex;
  align-items: center;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
}

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.logout-btn:hover {
  border-color: var(--text3);
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 30px;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(108,99,255,0.16), transparent 60%),
              radial-gradient(900px 500px at -10% 20%, rgba(255,101,132,0.10), transparent 55%),
              var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px 10px 0;
  margin-bottom: 14px;
  background: linear-gradient(to bottom, rgba(13,15,20,0.92), rgba(13,15,20,0.65));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.page-title {
  font-family: var(--font-head);
  font-size: 18px;
  letter-spacing: -0.2px;
  font-weight: 800;
  margin-right: auto;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

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

/* ==========================================================================
   5. COMPONENTES (CARDS, FLASHCARDS, ETC)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.07);
  flex: 0 0 auto;
}

.stat-i-classes { background: rgba(0, 210, 255, 0.08); border-color: rgba(0, 210, 255, 0.18); }
.stat-i-tasks { background: rgba(255, 159, 67, 0.10); border-color: rgba(255, 159, 67, 0.22); }
.stat-i-exams { background: rgba(255, 101, 132, 0.10); border-color: rgba(255, 101, 132, 0.22); }

.stat-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 22px;
  color: var(--text);
  font-weight: 900;
  letter-spacing: -0.01em;
}

.stat-label {
  color: var(--text2);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Flashcards */
.flashcards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.flashcard {
  perspective: 1000px;
  height: 200px;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.fc-front, .fc-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--border);
}

.fc-back {
  background: var(--accent);
  color: white;
  transform: rotateY(180deg);
}

/* Botão Flutuante (FAB) */
.fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow);
}

/* ==========================================================================
   6. RESPONSIVIDADE E STATUS
   ========================================================================== */
@media (max-width: 768px) {
  #main-app {
    display: block;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    padding: 14px 14px 26px;
  }

  .topbar {
    padding-left: 6px;
  }

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

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 18px;
  }
}

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3000;
  display: none;
  background: var(--warning);
  color: #111;
  text-align: center;
  padding: 10px 12px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

#sync-indicator {
  display: none;
}

#sync-indicator.spinning {
  animation: spin 1s linear infinite;
}
/* ==========================================================================
   INSTALL BANNER (PWA)
   ========================================================================== */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 20px 20px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.install-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.install-banner-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex-shrink: 0;
}

.install-banner-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.install-banner-text strong {
  font-family: var(--font-head);
  font-size: 1rem;
  color: var(--text);
}

.install-banner-text span {
  font-size: 0.82rem;
  color: var(--text2);
}

.install-banner-actions {
  display: flex;
  gap: 10px;
}

.install-btn-primary {
  flex: 1;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.install-btn-primary:hover {
  background: var(--accent-hover);
}

.install-btn-dismiss {
  padding: 12px 18px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.install-btn-dismiss:hover {
  color: var(--text);
  border-color: var(--text3);
}
