/* AulaZen — design system compartilhado (tokens de cor, tema claro/escuro,
   navegação, menu do usuário). As páginas usam as variáveis abaixo. */

:root {
  --bg: #e9eef9;
  --surface: #ffffff;
  --surface-2: #dde4f2;
  --text: #182033;
  --muted: #5b6880;
  --border: #6b7fa3;
  --primary: #2563eb;
  --primary-forte: #1d4ed8;
  --primary-contraste: #ffffff;
  --chip: #dde8ff;
  --chip-texto: #1d4ed8;
  --header: linear-gradient(120deg, #14286b 0%, #1d4ed8 60%, #3b82f6 100%);
  --sombra: 0 1px 4px rgba(23, 37, 84, 0.10);
  --sombra-alta: 0 8px 24px rgba(23, 37, 84, 0.16);
  --ok: #2e7d32; /* verde só como cor semântica de "resposta correta" */
}

html[data-tema="escuro"] {
  --bg: #0d1117;
  --surface: #161d29;
  --surface-2: #1f2836;
  --text: #e5eaf4;
  --muted: #92a0b8;
  --border: #2b3649;
  --primary: #5b8cff;
  --primary-forte: #8fb0ff;
  --primary-contraste: #0a1226;
  --chip: #1a2c55;
  --chip-texto: #a9c2ff;
  --header: linear-gradient(120deg, #0a1024 0%, #101c3f 70%, #16295e 100%);
  --sombra: 0 1px 4px rgba(0, 0, 0, 0.45);
  --sombra-alta: 0 8px 24px rgba(0, 0, 0, 0.55);
  --ok: #7bd88f;
}

html { color-scheme: light; }
html[data-tema="escuro"] { color-scheme: dark; }

body {
  /* textura: brilhos suaves de cor + grade de pontos sutil sobre o fundo */
  background:
    radial-gradient(1100px 500px at 85% -10%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 60%),
    radial-gradient(900px 420px at -10% 30%, color-mix(in srgb, var(--primary) 6%, transparent), transparent 55%),
    radial-gradient(color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 1px) 0 0 / 26px 26px,
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  transition: background 0.25s ease, color 0.25s ease;
}

/* ---------- barra do topo ---------- */
nav.topo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
}

nav.topo a, nav.topo button.tema-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary-forte);
  text-decoration: none;
  font-size: 14px;
  box-shadow: var(--sombra);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.1s ease;
}

nav.topo a:hover, nav.topo button.tema-btn:hover {
  background: var(--chip);
  transform: translateY(-1px);
}

nav.topo a.casa, nav.topo button.tema-btn {
  padding: 7px 11px;
  font-size: 16px;
  line-height: 1;
}

nav.topo button.tema-btn { margin-left: auto; }

/* variante pra fundos escuros fixos (lousa do quiz) */
nav.topo.escuro a { background: transparent; border-color: #f4f1e855; color: #f4f1e8; box-shadow: none; }
nav.topo.escuro a:hover { background: #ffffff22; }

/* ---------- menu suspenso do usuário (header da home) ---------- */
details.menu-usuario { position: relative; }

details.menu-usuario > summary {
  list-style: none;
  cursor: pointer;
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid #ffffff55;
  user-select: none;
}
details.menu-usuario > summary::-webkit-details-marker { display: none; }
details.menu-usuario > summary::after { content: " ▾"; font-size: 11px; opacity: 0.8; }
details.menu-usuario[open] > summary, details.menu-usuario > summary:hover { background: #ffffff22; }

details.menu-usuario .menu-itens {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--sombra-alta);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

details.menu-usuario .menu-itens a,
details.menu-usuario .menu-itens button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
}

details.menu-usuario .menu-itens a:hover,
details.menu-usuario .menu-itens button:hover { background: var(--surface-2); }

details.menu-usuario .menu-itens .separador {
  border-top: 1px solid var(--border);
  margin: 5px 8px;
}

/* ---------- dropdown-conta (assinatura + dados + alterar) ---------- */
.conta-menu { min-width: 288px; padding: 16px !important; border-radius: 14px !important; }

.conta-menu .bloco-assinatura .rotulo {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 2.2px;
  font-weight: 700; color: var(--muted); margin-bottom: 8px;
}
.conta-menu .selo {
  display: inline-block; padding: 5px 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; letter-spacing: 0.2px;
  background: var(--chip); color: var(--chip-texto);
}
.conta-menu .bloco-assinatura p {
  margin: 8px 0 2px; font-size: 12.5px; line-height: 1.5; color: var(--muted);
}
/* Botão de assinar — chamativo: gradiente, brilho que atravessa, pulso suave.
   Texto branco fixo (o gradiente é saturado nos 2 temas). */
.btn-assinar {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 55%, #db2777 115%);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 45%, transparent);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  animation: btn-assinar-pulso 2.8s ease-in-out infinite;
}
.btn-assinar::before {
  content: "✨";
  font-size: 15px;
  line-height: 1;
}
.btn-assinar::after {
  /* faixa de brilho que atravessa o botão de tempos em tempos */
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 45%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: btn-assinar-brilho 3.2s ease-in-out infinite;
}
.btn-assinar:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 60%, transparent);
}
/* no dropdown da conta ocupa a largura toda, como antes */
.conta-menu .btn-assinar { width: 100%; margin-top: 10px; }

@keyframes btn-assinar-pulso {
  0%, 100% { box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 45%, transparent); }
  50% { box-shadow: 0 4px 22px color-mix(in srgb, #7c3aed 55%, transparent); }
}
@keyframes btn-assinar-brilho {
  0%, 55% { left: -80%; }
  100% { left: 130%; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-assinar, .btn-assinar::after { animation: none; }
  .btn-assinar:hover { transform: none; }
}
.conta-menu .bloco-dados { display: flex; flex-direction: column; gap: 3px; padding: 6px 2px; }
.conta-menu .bloco-dados strong {
  font-size: 15.5px; font-weight: 650; letter-spacing: 0.1px;
}
.conta-menu .bloco-dados span { font-size: 13px; color: var(--muted); letter-spacing: 0.1px; }
.conta-menu .bloco-dados a#abrir-alterar {
  align-self: flex-end; font-size: 11.5px; color: #c0392b;
  text-decoration: underline; cursor: pointer; padding: 2px;
}

.conta-menu form#form-alterar { display: flex; flex-direction: column; gap: 7px; padding: 8px 2px 4px; }
.conta-menu form#form-alterar input { width: 100%; padding: 8px 10px; font-size: 13px; }
.conta-menu form#form-alterar button {
  padding: 8px; border: none; border-radius: 7px; font-weight: 600; cursor: pointer;
  background: var(--primary); color: var(--primary-contraste);
}
.conta-menu #alt-msg { min-height: 14px; font-size: 12px; }
.conta-menu #alt-msg.erro { color: #c0392b; }
.conta-menu #alt-msg.ok { color: var(--primary-forte); }

.conta-menu button.sair {
  justify-content: center !important;
  text-align: center !important;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted) !important;
}

/* ---------- imagens de questão ---------- */
img.q-img {
  display: block;
  max-width: 100%;
  max-height: 460px; /* maior na tela: muitas imagens vinham pequenas demais */
  border-radius: 8px;
  margin: 8px 0;
  background: #fff; /* PNG transparente precisa de fundo claro em qualquer tema */
  cursor: zoom-in;
}

/* referência bibliográfica dentro do texto rico da questão: linha própria,
   menor e um pouco mais cinza que o texto (bom no tema claro E escuro) */
.ref {
  display: block;
  margin-top: 6px;
  font-size: 0.8em;
  line-height: 1.4;
  color: var(--muted);
}

/* Lightbox: img.q-img ampliada em tela cheia (criada por questao-render.js) */
.q-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.q-lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  cursor: default;
}
.q-lightbox-fechar {
  position: fixed;
  top: 16px;
  right: 20px;
  width: 48px;
  height: 48px;
  font-size: 26px;
  line-height: 1;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}
.q-lightbox-fechar:hover { background: rgba(255, 255, 255, 0.32); }

@media print {
  .q-lightbox { display: none !important; } /* nunca imprime o lightbox */
}

/* ---------- texto-base de questão (lecturas, textos de referência) ---------- */
details.texto-base {
  margin: 0 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: .92em;
  background: var(--surface-2);
}
details.texto-base summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details.texto-base .texto-base-corpo { margin-top: 8px; white-space: pre-wrap; line-height: 1.5; }
.numero-fora-quadro { font-weight: 600; margin: 6px 0 -2px; }
.texto-base-impresso { white-space: pre-wrap; line-height: 1.5; border: 1px solid #999; border-radius: 6px; padding: 8px 12px; margin: 6px 0 10px; }
.texto-base-lousa {
  white-space: pre-wrap;
  font-size: clamp(15px, 1.6vw, 20px);
  line-height: 1.45;
  max-height: 30vh;
  overflow-y: auto;
  border-left: 4px solid rgba(255, 255, 255, .4);
  padding: 4px 12px;
  margin-bottom: 18px;
  text-align: left;
}
.texto-base-lousa:empty { display: none; }

/* ---------- Minhas Questões: tags coloridas de pasta ---------- */
.pastas-da-questao { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-pasta {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .3px;
  cursor: pointer;
  box-shadow: var(--sombra);
}
.tag-pasta:hover { filter: brightness(1.15); }
.pasta-cor {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  flex: none;
}

/* ---------- rodapé ---------- */
footer.rodape {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  padding: 26px 16px 18px;
  letter-spacing: 0.4px;
}

a.sac-whats {
  position: fixed;
  right: 14px;
  bottom: 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-forte);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  text-decoration: none;
  box-shadow: var(--sombra-alta);
  z-index: 40;
}
a.sac-whats:hover { background: var(--chip); }
@media print { footer.rodape, a.sac-whats, .fale-conosco-btn, .fale-conosco-painel { display: none; } }

/* ---------- "Fale conosco" (widget de chat com o admin) ---------- */
.fale-conosco-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary-contraste);
  background: var(--primary);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: var(--sombra-alta);
  z-index: 60;
  cursor: pointer;
}
.fale-conosco-btn:hover { filter: brightness(1.08); }

.fale-conosco-badge {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #d33;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  line-height: 18px;
}
.fale-conosco-badge.mostrar { display: inline-flex; }

.fale-conosco-painel {
  position: fixed;
  right: 14px;
  bottom: 70px;
  width: 320px;
  max-width: calc(100vw - 28px);
  max-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--sombra-alta);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 60;
}
.fale-conosco-painel.aberto { display: flex; }

.fale-conosco-painel .fc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--header);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex: none;
}
.fale-conosco-painel .fc-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
/* título empurra os botões (lixeira + fechar) juntos pra direita */
.fale-conosco-painel .fc-header > span:first-child { margin-right: auto; }
.fale-conosco-painel .fc-header .fc-lixeira { font-size: 15px; opacity: 0.85; }
.fale-conosco-painel .fc-header .fc-lixeira:hover { opacity: 1; }

.fale-conosco-painel .fc-mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
}
.fc-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.4;
  word-break: break-word;
}
.fc-bubble.fc-user { align-self: flex-end; background: var(--primary); color: var(--primary-contraste); border-bottom-right-radius: 3px; }
.fc-bubble.fc-admin { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 3px; }
.fc-bubble div { white-space: pre-wrap; }
.fc-hora { display: block; font-size: 10px; opacity: .7; margin-top: 3px; }
.fc-vazio { text-align: center; color: var(--muted); font-size: 13px; margin: auto; }

.fale-conosco-painel .fc-form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex: none;
}
.fale-conosco-painel .fc-form textarea {
  flex: 1;
  resize: none;
  min-height: 36px;
  max-height: 90px;
  padding: 7px 9px;
  font-size: 13px;
}
.fale-conosco-painel .fc-enviar {
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-contraste);
  font-weight: 600;
  cursor: pointer;
}
.fc-erro { font-size: 11.5px; color: #c0392b; padding: 0 10px 8px; min-height: 14px; flex: none; }

@media (max-width: 480px) {
  .fale-conosco-painel { right: 8px; left: 8px; width: auto; bottom: 64px; }
  .fale-conosco-btn { right: 8px; bottom: 8px; }
}

/* ---------- polimentos globais ---------- */
::selection { background: var(--chip); }
button { font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ---------- responsivo (telas pequenas) ---------- */
@media (max-width: 640px) {
  details.menu-usuario .menu-itens { max-width: calc(100vw - 24px); }
  .conta-menu { max-width: calc(100vw - 24px); }
}

/* === marca/logo === */
.logo-wordmark {
  display: block;
  height: 30px;
  width: auto;
}
.logo-login {
  display: block;
  max-width: 280px;
  width: 100%;
  height: auto;
  margin: 0 auto 4px;
}
/* o wordmark é azul com contorno claro; reforça a legibilidade no tema escuro */
html[data-tema="escuro"] .logo-wordmark,
html[data-tema="escuro"] .logo-login {
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, .6));
}
