/* ── Reset e variáveis ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-900: #1e3a8a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --green-600: #16a34a;
  --green-100: #dcfce7;
  --yellow-600: #ca8a04;
  --yellow-100: #fef9c3;
  --red-600: #dc2626;
  --red-100:  #fee2e2;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.1);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--slate-900);
  background: var(--slate-50);
  line-height: 1.6;
}

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

.sidebar {
  width: 240px;
  background: var(--blue-900);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.sidebar-brand p {
  font-size: 0.75rem;
  opacity: .7;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background .15s, color .15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.1);
  color: var(--white);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 0.8rem;
  opacity: .6;
}

.main-content {
  flex: 1;
  overflow: auto;
  padding: 32px;
}

/* ── Autenticação (tela central) ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 100%);
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  font-size: 1.5rem;
  color: var(--blue-900);
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--slate-500);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ── Formulários ── */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--slate-900);
  background: var(--white);
  transition: border-color .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

textarea { resize: vertical; min-height: 80px; }

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
}

.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--blue-600);  color: var(--white); }
.btn-secondary { background: var(--slate-100); color: var(--slate-700); }
.btn-success   { background: var(--green-600); color: var(--white); }
.btn-danger    { background: var(--red-600);   color: var(--white); }
.btn-outline   { background: transparent; border: 1.5px solid var(--blue-500); color: var(--blue-600); }
.btn-full      { width: 100%; justify-content: center; }
.btn-sm        { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg        { padding: 14px 28px; font-size: 1rem; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate-900);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-alta    { background: var(--green-100);  color: var(--green-600); }
.badge-media   { background: var(--yellow-100); color: var(--yellow-600); }
.badge-baixa   { background: var(--red-100);    color: var(--red-600); }
.badge-blue    { background: var(--blue-100);   color: var(--blue-700); }
.badge-gray    { background: var(--slate-100);  color: var(--slate-700); }

/* ── Alertas ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert-error   { background: var(--red-100);    color: var(--red-600); border-left: 3px solid var(--red-600); }
.alert-warning { background: var(--yellow-100); color: var(--yellow-600); border-left: 3px solid var(--yellow-600); }
.alert-info    { background: var(--blue-50);    color: var(--blue-700); border-left: 3px solid var(--blue-500); }
.alert-success { background: var(--green-100);  color: var(--green-600); border-left: 3px solid var(--green-600); }

/* ── Progress bar ── */
.progress-wrap {
  background: var(--slate-100);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: var(--blue-500);
  transition: width .4s ease;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-header h2 {
  font-size: 1.5rem;
  color: var(--slate-900);
}

.page-header p {
  color: var(--slate-500);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* ── Grid de turmas ── */
.turmas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.turma-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .2s, transform .15s;
  display: block;
  cursor: pointer;
}

.turma-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.turma-card h3 {
  font-size: 1rem;
  color: var(--blue-900);
  margin-bottom: 4px;
}

.turma-card .disciplina {
  font-size: 0.85rem;
  color: var(--slate-500);
  margin-bottom: 12px;
}

.turma-card .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ── Chat (aluno) ── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--slate-50);
}

.chat-header {
  background: var(--blue-900);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header h1 { font-size: 1rem; }
.chat-header p  { font-size: 0.8rem; opacity: .75; margin-top: 1px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 0.9rem;
}

.message.ai {
  background: var(--white);
  box-shadow: var(--shadow);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message.user {
  background: var(--blue-600);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.typing {
  background: var(--white);
  box-shadow: var(--shadow);
  align-self: flex-start;
  color: var(--slate-500);
  font-style: italic;
  font-size: 0.85rem;
}

.chat-footer {
  background: var(--white);
  border-top: 1px solid var(--slate-300);
  padding: 12px 20px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 14px;
  resize: none;
}

.progress-indicator {
  font-size: 0.78rem;
  color: var(--slate-500);
  text-align: center;
  margin-bottom: 8px;
}

/* ── Wizard (steps) ── */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
}

.wizard-step {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 0.82rem;
  color: var(--slate-500);
  border-bottom: 3px solid var(--slate-200);
  transition: all .2s;
}

.wizard-step.active {
  color: var(--blue-700);
  border-bottom-color: var(--blue-600);
  font-weight: 600;
}

.wizard-step.done {
  color: var(--green-600);
  border-bottom-color: var(--green-600);
}

/* ── Checkbox grid para eixos ── */
.eixos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.eixo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.eixo-item:hover { border-color: var(--blue-400); }
.eixo-item.selected { border-color: var(--blue-500); background: var(--blue-50); }
.eixo-item input { display: none; }
.eixo-item .check {
  width: 18px; height: 18px;
  border: 2px solid var(--slate-300);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  transition: all .15s;
}
.eixo-item.selected .check {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: white;
}

/* ── Radar chart wrapper ── */
.radar-container {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal h2 { color: var(--blue-900); margin-bottom: 12px; }
.modal p  { color: var(--slate-700); line-height: 1.6; margin-bottom: 20px; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ── Link mágico ── */
.link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.link-box .link-text {
  flex: 1;
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--blue-700);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--slate-200);
  margin: 24px 0;
}

/* ── Misc ── */
.text-muted  { color: var(--slate-500); font-size: 0.875rem; }
.text-center { text-align: center; }
.mt-4  { margin-top: 16px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Spinner ── */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: rgba(0,0,0,.1);
  border-top-color: var(--blue-600);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Print styles ── */
@media print {
  .sidebar, .no-print, button, .btn, nav { display: none !important; }
  .main-content { padding: 0; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #e2e8f0; }
  #report-content { display: block !important; }
  a { color: inherit; text-decoration: none; }
}

/* ── Responsivo ── */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav { display: flex; flex-direction: row; overflow-x: auto; }
  .sidebar-nav a { padding: 8px 12px; white-space: nowrap; }
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; }
  .turmas-grid { grid-template-columns: 1fr; }
}
