/* Arrais Quiz — CSS puro, mobile-first, sem framework externo.
   Paleta inspirada no print do usuário (azul primário forte + branco). */

:root {
  --primary: #1DA1F2;
  --primary-dark: #0f8bd8;
  --primary-hover: #1893e3;
  --success: #22c55e;
  --success-dark: #16a34a;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --neutral-50: #f9fafb;
  --neutral-100: #f3f4f6;
  --neutral-200: #e5e7eb;
  --neutral-300: #d1d5db;
  --neutral-400: #9ca3af;
  --neutral-500: #6b7280;
  --neutral-700: #374151;
  --neutral-800: #1f2937;
  --neutral-900: #111827;
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(29,161,242,.25);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--neutral-800);
  background: var(--neutral-50);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 80px; /* espaço pra footer nav mobile */
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout container */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}
@media (min-width: 1024px) {
  .container { max-width: 960px; padding: 24px; }
}

/* Header */
.hdr {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky; top: 0; z-index: 10;
}
.hdr-logo {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hdr-logo:hover { text-decoration: none; }
.hdr a { color: white; }
.hdr-actions { display: flex; align-items: center; gap: 12px; font-size: .9rem; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
  margin-bottom: 16px;
}
.card-blue { background: var(--primary); color: white; }
.card-blue h1, .card-blue h2, .card-blue h3 { color: white; }

/* Typography */
h1 { font-size: 1.6rem; margin: 0 0 12px; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; margin: 0 0 10px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; color: var(--neutral-700); }
.muted { color: var(--neutral-500); font-size: .9rem; }
.small { font-size: .85rem; }

/* Buttons — GRANDES E FÁCEIS de tocar (min 56px) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: white;
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: scale(.98); box-shadow: none; }
.btn-outline {
  background: white;
  color: var(--primary-dark);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--neutral-100); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); }
.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-dark); }
.btn-sm { min-height: 40px; padding: 8px 16px; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--primary-dark); box-shadow: none; }
.btn-ghost:hover { background: var(--neutral-100); }

@media (min-width: 640px) {
  .btn-auto { width: auto; }
}

/* Formulários */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--neutral-700);
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 2px solid var(--neutral-200);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
}
.field textarea { min-height: 80px; }

/* Alternativas do quiz */
.alt-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--neutral-200);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  min-height: 64px;
  margin-bottom: 12px;
  transition: all .12s ease;
  text-align: left;
  width: 100%;
  font-size: 1rem;
  font-family: inherit;
  color: var(--neutral-800);
}
.alt-card:hover { border-color: var(--primary); background: var(--neutral-50); }
.alt-card:active { transform: scale(.99); }
.alt-letra {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
}
.alt-card.selecionada { border-color: var(--primary); background: #eaf5fe; }
.alt-card.correta {
  border-color: var(--success);
  background: #ecfdf5;
}
.alt-card.correta .alt-letra { background: var(--success); }
.alt-card.errada {
  border-color: var(--danger);
  background: #fef2f2;
}
.alt-card.errada .alt-letra { background: var(--danger); }
.alt-card:disabled { cursor: default; }

/* Progress bar */
.progress {
  background: var(--neutral-200);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width .3s ease;
  border-radius: 999px;
}

/* Result screen — YOU WIN / YOU LOST */
.result-hero {
  text-align: center;
  padding: 40px 20px;
  border-radius: var(--radius);
  color: white;
  margin: 20px 0;
}
.result-win { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }
.result-loss { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.result-hero h1 {
  font-size: 3rem;
  color: white;
  margin: 0;
  letter-spacing: -0.05em;
  font-weight: 900;
}
.result-hero .score {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 12px 0;
}
.result-hero .sub { font-size: 1.1rem; opacity: .95; }

/* Feedback (após responder) */
.feedback-box {
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  font-weight: 600;
}
.feedback-ok { background: #ecfdf5; color: var(--success-dark); border: 2px solid var(--success); }
.feedback-err { background: #fef2f2; color: var(--danger-dark); border: 2px solid var(--danger); }

/* Fundamento expansível */
.fund-box { border-top: 2px solid var(--neutral-200); margin-top: 16px; padding-top: 12px; }
.fund-toggle {
  width: 100%;
  padding: 12px;
  background: var(--neutral-100);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--neutral-700);
  font-size: .95rem;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: inherit;
}
.fund-toggle:hover { background: var(--neutral-200); }
.fund-toggle .chev { transition: transform .2s; }
.fund-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.fund-content { padding: 12px 4px; display: none; }
.fund-content.open { display: block; }
.fund-item { padding: 10px; border-radius: 8px; margin-bottom: 8px; }
.fund-item.correta { background: #ecfdf5; border-left: 4px solid var(--success); }
.fund-item.errada { background: #fef2f2; border-left: 4px solid var(--danger); }
.fund-fonte { font-size: .8rem; color: var(--neutral-500); font-style: italic; margin-top: 8px; }

/* Toast de conquista */
.toast {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 100;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  animation: toastIn .4s ease-out;
  max-width: 320px;
}
@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.toast strong { display: block; font-size: 1.1rem; }
.toast .toast-icon { font-size: 1.8rem; }

/* Grid genérico */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* Tema cards */
.tema-card {
  display: block;
  padding: 20px 16px;
  background: white;
  border-radius: var(--radius);
  border: 2px solid var(--neutral-200);
  text-align: center;
  transition: all .15s;
  color: var(--neutral-800);
  cursor: pointer;
}
.tema-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); text-decoration: none; }
.tema-card .icone { font-size: 2.4rem; }
.tema-card .nome { font-weight: 700; margin: 8px 0 4px; }
.tema-card .stat { font-size: .85rem; color: var(--neutral-500); }
.tema-card .barra { margin-top: 8px; height: 6px; background: var(--neutral-200); border-radius: 999px; overflow: hidden; }
.tema-card .barra-fill { height: 100%; background: var(--primary); transition: width .3s; }

/* Stat tiles */
.stat-tile {
  padding: 16px;
  background: white;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--neutral-200);
}
.stat-tile .val { font-size: 1.8rem; font-weight: 800; color: var(--primary-dark); }
.stat-tile .lbl { font-size: .8rem; color: var(--neutral-500); text-transform: uppercase; letter-spacing: .05em; }

/* Conquistas */
.conquista {
  padding: 16px 12px;
  border-radius: 12px;
  text-align: center;
  background: white;
  border: 2px solid var(--neutral-200);
  transition: all .15s;
}
.conquista.desbloqueada {
  border-color: var(--warning);
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}
.conquista.bloqueada { opacity: .45; filter: grayscale(90%); }
.conquista .ic { font-size: 2.4rem; margin-bottom: 4px; }
.conquista .nm { font-weight: 700; font-size: .95rem; }
.conquista .ds { font-size: .8rem; color: var(--neutral-500); margin-top: 4px; }

/* ===== Sidebar (desktop) ===== */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    background: white;
    border-right: 1px solid var(--neutral-200);
    box-shadow: 2px 0 6px rgba(0,0,0,.04);
    z-index: 20;
    transition: width .2s ease;
  }
  html.sidebar-recolhida .sidebar { width: 72px; }
  html.sidebar-recolhida .sidebar .lbl,
  html.sidebar-recolhida .sidebar-logo-text { display: none; }
  html.sidebar-recolhida .sidebar-toggle .chev { transform: rotate(180deg); }

  /* Header fica escondido em desktop — sidebar cobre */
  .hdr { display: none; }
  /* Bottom nav some em desktop */
  .bottom-nav { display: none !important; }
  /* Conteúdo desloca pra direita da sidebar */
  .app-main { margin-left: 240px; padding-top: 24px; transition: margin-left .2s ease; }
  html.sidebar-recolhida .app-main { margin-left: 72px; }
  body { padding-bottom: 0; }
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border-bottom: 1px solid var(--neutral-200);
  min-height: 60px;
}
.sidebar-logo {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary-dark);
  text-decoration: none;
  overflow: hidden;
}
.sidebar-logo:hover { text-decoration: none; }
.sidebar-logo-icon { font-size: 1.6rem; flex-shrink: 0; }
.sidebar-logo-text { white-space: nowrap; }
.sidebar-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--neutral-500);
  font-size: .9rem;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background .15s;
}
.sidebar-toggle:hover { background: var(--neutral-100); color: var(--primary-dark); }
.sidebar-toggle .chev { display: inline-block; transition: transform .2s ease; }
html.sidebar-recolhida .sidebar-header { justify-content: center; }
html.sidebar-recolhida .sidebar-logo { flex: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--neutral-700);
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
  transition: all .12s;
  min-height: 44px;
}
.sidebar-link:hover { background: var(--neutral-100); color: var(--primary-dark); text-decoration: none; }
.sidebar-link.active {
  background: linear-gradient(90deg, #eaf5fe, #f0f9ff);
  color: var(--primary-dark);
  box-shadow: inset 3px 0 0 var(--primary);
}
.sidebar-link .ic { font-size: 1.3rem; flex-shrink: 0; width: 24px; text-align: center; }
.sidebar-link .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.sidebar-recolhida .sidebar-link { justify-content: center; padding: 12px 8px; }

.sidebar-footer {
  border-top: 1px solid var(--neutral-200);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--neutral-500);
  font-size: .85rem;
  font-weight: 600;
}
.sidebar-user .ic { font-size: 1.2rem; }
html.sidebar-recolhida .sidebar-user { justify-content: center; padding: 10px 8px; }

/* Footer bottom nav (mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid var(--neutral-200);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 10;
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 6px;
  color: var(--neutral-500);
  font-size: .75rem;
  font-weight: 600;
}
.bottom-nav a .ic { display: block; font-size: 1.4rem; }
.bottom-nav a.active { color: var(--primary-dark); }
.bottom-nav a:hover { text-decoration: none; }

/* Cronômetro */
.cronometro {
  position: sticky;
  top: 56px;
  background: white;
  padding: 8px 16px;
  border-bottom: 1px solid var(--neutral-200);
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary-dark);
  z-index: 5;
}
.cronometro.alerta { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: .5; }
}

/* Tabelas */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--neutral-200); }
th { color: var(--neutral-500); font-weight: 600; font-size: .85rem; text-transform: uppercase; }

/* Utility */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-danger { color: var(--danger-dark); }
.text-success { color: var(--success-dark); }
.text-muted { color: var(--neutral-500); }
