/* ═══════════════════════════════════════════════════════════════
   SIMULADOS SME — v1.0.0 — Design System SME
   Plataforma: simulados | Stack: HTML/CSS/JS puro
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary: #1565C0;
  --primary-hover: #0d47a1;
  --primary-soft: #E3F2FD;
  --bg-start: #f0f4f8;
  --bg-end: #e2e8f0;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  /* Faixas pedagógicas */
  --c-avancado: #16a34a;
  --c-proficiente: #1565C0;
  --c-basico: #d97706;
  --c-abaixo: #dc2626;
  --c-faltou: #6b7280;
}

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

html, body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--primary); text-decoration: none; }

/* ─── Login ─────────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#login-screen.hidden { display: none; }

.login-card {
  background: var(--surface);
  max-width: 420px; width: 100%;
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.login-logo img { width: 80px; height: 80px; object-fit: contain; }
.login-title { text-align: center; font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.login-subtitle { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 28px; text-transform: uppercase; letter-spacing: 0.5px; }
.field { margin-bottom: 18px; }
.field label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.5px;
}
.field label i { color: var(--primary); width: 14px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { resize: vertical; min-height: 60px; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; font-size: 13px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.full { width: 100%; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); color: var(--primary);
  border: 1.5px solid var(--primary);
  font-weight: 700; font-size: 13px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--primary-soft); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--danger); color: #fff;
  font-weight: 700; font-size: 13px;
  padding: 10px 20px; border-radius: var(--radius-sm);
}
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 13px;
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.btn-ghost:hover { color: var(--primary); background: var(--primary-soft); }

.login-footer { text-align: center; margin-top: 18px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── Shell ─────────────────────────────────────────────────── */
#shell.hidden { display: none; }

.header {
  background: var(--surface);
  border-bottom: 4px solid var(--primary);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-logo { width: 44px; height: 44px; object-fit: contain; }
.header-title { font-weight: 700; color: var(--primary); font-size: 16px; line-height: 1.1; }
.header-subtitle { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.user-info { text-align: right; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); }

.main {
  max-width: 1280px; margin: 0 auto;
  padding: 28px 24px;
}

/* ─── Views ────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.page-title i { font-size: 22px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ─── Cards & containers ───────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }

.empty-state {
  text-align: center; padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 42px; color: var(--primary-soft); margin-bottom: 14px; }
.empty-state p { margin-bottom: 14px; }

/* ─── Tabela de simulados (dashboard) ──────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th { background: #f8fafc; font-weight: 700; color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px; }
.tbl tr:hover td { background: #fafbfc; }
.tbl .actions { text-align: right; white-space: nowrap; }

.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.status-rascunho { background: #f3f4f6; color: var(--text-muted); }
.status-preenchimento { background: #fef3c7; color: #b45309; }
.status-finalizado { background: #dcfce7; color: #15803d; }

/* ─── Wizard steps ─────────────────────────────────────────── */
.wizard-steps {
  display: flex; gap: 6px; margin-bottom: 24px;
  background: var(--surface); padding: 14px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.wizard-step {
  flex: 1; text-align: center; padding: 8px 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.wizard-step.active { background: var(--primary); color: #fff; }
.wizard-step.done { background: var(--primary-soft); color: var(--primary); }
.wizard-step .num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,0.25); font-weight: 700; }
.wizard-step.done .num { background: var(--primary); color: #fff; }

.wizard-actions {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
}

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.form-grid-full { grid-column: 1 / -1; }

/* ─── Tabela de metadados itens (Step 2) ───────────────────── */
.itens-tabela th, .itens-tabela td { padding: 9px 8px; vertical-align: middle; }
.itens-tabela .col-ordem { width: 50px; text-align: center; font-weight: 700; color: var(--primary); }
.itens-tabela select, .itens-tabela input {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); font-size: 13px;
}
.itens-tabela select:focus, .itens-tabela input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft);
}
.col-gabarito { width: 90px; }
.col-peso { width: 80px; }
.col-dif { width: 130px; }
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 240px; overflow-y: auto; box-shadow: var(--shadow-md);
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-size: 12px; border-bottom: 1px solid #f3f4f6; }
.autocomplete-item:hover, .autocomplete-item.hl { background: var(--primary-soft); }
.autocomplete-item .codigo { font-weight: 700; color: var(--primary); margin-right: 6px; }

/* ─── Grade respostas (Step 3) ─────────────────────────────── */
.grade-respostas {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
}
.grade-respostas th, .grade-respostas td {
  border: 1px solid var(--border); padding: 6px 4px; text-align: center;
}
.grade-respostas th { background: var(--primary-soft); color: var(--primary); font-weight: 700; text-transform: uppercase; font-size: 11px; }
.grade-respostas .col-aluno { text-align: left; min-width: 200px; font-weight: 500; }
.grade-respostas .col-faltou { width: 72px; }
.grade-respostas .col-resposta { width: 64px; }
.grade-respostas tr.faltou .col-aluno { color: var(--text-muted); text-decoration: line-through; }
.grade-respostas tr.faltou .col-resposta select { background: #f3f4f6; color: var(--text-muted); }
.grade-respostas select { width: 56px; padding: 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.grade-respostas input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

/* ─── Devolutiva ───────────────────────────────────────────── */
.metrics-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.metric {
  background: var(--surface); padding: 16px;
  border-radius: var(--radius-md); border-left: 4px solid var(--primary);
}
.metric-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.metric-value { font-size: 24px; font-weight: 700; color: var(--text); margin-top: 4px; }
.metric-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.dist-bars { display: flex; flex-direction: column; gap: 10px; }
.dist-row { display: grid; grid-template-columns: 140px 1fr 60px; gap: 10px; align-items: center; }
.dist-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.dist-bar-wrap { height: 22px; background: #f3f4f6; border-radius: 11px; overflow: hidden; }
.dist-bar { height: 100%; transition: width 0.4s; }
.dist-bar.avancado { background: var(--c-avancado); }
.dist-bar.proficiente { background: var(--c-proficiente); }
.dist-bar.basico { background: var(--c-basico); }
.dist-bar.abaixo { background: var(--c-abaixo); }
.dist-pct { font-size: 12px; font-weight: 700; text-align: right; }

.barlist { display: flex; flex-direction: column; gap: 8px; }
.barlist-row { display: grid; grid-template-columns: 1fr 60px; gap: 10px; align-items: center; }
.barlist-row .top { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.barlist-row .top .codigo { font-weight: 700; color: var(--primary); }
.barlist-row .top .desc { color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-bar-wrap { grid-column: 1 / -1; height: 8px; background: #f3f4f6; border-radius: 4px; overflow: hidden; }
.barlist-bar { height: 100%; background: var(--primary); transition: width 0.4s; }

.devolutiva-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; padding: 12px; background: var(--primary-soft); border-radius: var(--radius-md); margin-bottom: 18px; }
.devolutiva-meta-item { font-size: 12px; }
.devolutiva-meta-item .lbl { color: var(--text-muted); text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: 0.4px; }
.devolutiva-meta-item .val { color: var(--text); font-weight: 600; margin-top: 2px; }

.classif-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #fff; }
.classif-AVANCADO { background: var(--c-avancado); }
.classif-PROFICIENTE { background: var(--c-proficiente); }
.classif-BASICO { background: var(--c-basico); }
.classif-ABAIXO { background: var(--c-abaixo); }
.classif-FALTOU { background: var(--c-faltou); }

.respostas-mini { display: inline-flex; gap: 2px; }
.respostas-mini .r { display: inline-block; min-width: 20px; padding: 1px 4px; border-radius: 4px; font-size: 10px; font-weight: 700; text-align: center; }
.respostas-mini .r.ok { background: #dcfce7; color: var(--c-avancado); }
.respostas-mini .r.no { background: #fee2e2; color: var(--c-abaixo); }
.respostas-mini .r.null { background: #f3f4f6; color: var(--text-muted); }

/* ─── Resumo Step 4 ─────────────────────────────────────────── */
.resumo-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.resumo-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: #f8fafc; border-radius: var(--radius-sm); border-left: 3px solid var(--primary); }
.resumo-row .lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; letter-spacing: 0.4px; }
.resumo-row .val { font-size: 14px; font-weight: 600; color: var(--text); }

/* ─── Loading overlay ──────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(255,255,255,0.7); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
}
#loading-overlay.show { display: flex; }
#loading-overlay .spinner { color: var(--primary); font-size: 42px; }

/* ─── Toast ────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9500; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  background: var(--surface); padding: 12px 16px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 10px;
  border-left: 4px solid var(--primary);
  animation: slideIn 0.25s ease-out;
  font-size: 13px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast i { color: var(--primary); }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 9200;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  max-width: 440px; width: 100%; padding: 28px;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.modal-title i { color: var(--danger); }
.modal-body { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Responsividade ───────────────────────────────────────── */
@media (max-width: 720px) {
  .main { padding: 18px 14px; }
  .header { padding: 12px 14px; }
  .header-title { font-size: 14px; }
  .header-subtitle { display: none; }
  .user-info { display: none; }
  .login-card { padding: 28px 22px; }
  .wizard-step { font-size: 9px; }
  .wizard-step .label-text { display: none; }
  .tbl th, .tbl td { padding: 8px 6px; font-size: 12px; }
  .grade-respostas { font-size: 11px; }
  .grade-respostas .col-aluno { min-width: 140px; }
}

