/* ──────────────────────────────────────
   Revisa — Ajustes de layout, texto e fonte
   Carregado logo depois do theme.css em todas
   as páginas. Mexe só em CSS: largura, tamanhos,
   alturas mínimas e fonte.
   ────────────────────────────────────── */

/* ── Tokens de texto (ajuste em um lugar só) ── */
:root {
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.75rem;
  --text-num: 2.25rem;
  --color-muted: #556079;
  --color-sidebar-muted: #a9b2c8;
  --font-heading: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --font-body: 'Fredoka', ui-rounded, system-ui, sans-serif;
}

/* ── Fonte única: Fredoka ── */
html,
body,
*,
*::before,
*::after {
  font-family: 'Fredoka', ui-rounded, system-ui, sans-serif !important;
}

body {
  font-size: var(--text-base) !important;
  line-height: 1.55 !important;
}

/* ── Largura do conteúdo (preenche até a borda direita) ── */
@media (min-width: 1024px) {
  main.lg\:ml-60 {
    width: calc(100% - 15rem) !important;
    max-width: none !important;
    margin-left: 15rem !important;
    margin-right: 0 !important;
    box-sizing: border-box;
  }

  main>* {
    max-width: 1680px !important;
    margin-left: 0 !important;
    margin-right: auto !important;
  }
}

@media (min-width: 1921px) {
  main>* {
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* ── Títulos ── */
main>header h1,
#view-list>header h1,
#view-detail h1,
#view-deck h1 {
  font-size: 1.5rem !important;
  line-height: 1.2 !important;
}

main>header p,
#view-list>header p {
  font-size: var(--text-sm) !important;
}

main h2,
main h3 {
  font-size: var(--text-lg) !important;
}

/* Números grandes dos cartões de estatística */
main .text-3xl {
  font-size: var(--text-num) !important;
}

/* ── Textos pequenos: nada abaixo de 13px ── */
.text-xs,
.text-\[10px\],
.text-\[11px\],
.tag,
.badge,
.status-pill,
.plan-main-badge,
.tab-count,
.sim-chip-count {
  font-size: var(--text-xs) !important;
}

.text-\[11px\] {
  font-size: 0.875rem !important;
}

.text-sm {
  font-size: var(--text-sm) !important;
}

/* ── Menu lateral ── */
body>div>aside[class] .nav-link {
  font-size: var(--text-sm) !important;
  min-height: 44px !important;
  line-height: 1.3 !important;
}

body>div>aside[class] .nav-link .nav-icon,
.nav-link .nav-icon {
  width: 20px !important;
  height: 20px !important;
}

body>div>aside[class] .nav-link .nav-icon svg,
.nav-link .nav-icon svg {
  width: 20px !important;
  height: 20px !important;
}

body>div>aside[class]>a:first-child {
  font-size: 1.125rem !important;
}

body>div>aside[class] [data-user-name] {
  font-size: var(--text-sm) !important;
}

body>div>aside[class] [data-reset-all],
body>div>aside[class] [data-logout] {
  font-size: var(--text-xs) !important;
}

/* Mantém cada item do menu com a mesma geometria, inclusive quando ativo. */
body > div > aside[class] nav .nav-link,
body > div > aside[class] nav .nav-link:hover,
body > div > aside[class] nav .nav-link.active,
body > div > aside[class] nav .nav-link.active:hover {
  box-sizing: border-box !important;
  flex-shrink: 0;
  font-weight: 500 !important;
  transform: none !important;
  translate: none !important;
  margin: 0 0 2px !important;
  padding: 8px 12px !important;
  min-height: 44px !important;
  line-height: 1.3 !important;
}

/* Só a lista rola quando a altura da tela não comporta todo o menu. */
@media (min-width: 1024px) {
  body > div > aside[class] nav {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body > div > aside[class] > a:first-child,
  body > div > aside[class] > .mt-auto {
    flex-shrink: 0;
  }
}

/* Menu estável: a seleção nunca altera as dimensões ou anima os ícones. */
body > div > aside[class] nav .nav-link,
body > div > aside[class] nav .nav-link:hover,
body > div > aside[class] nav .nav-link.active,
body > div > aside[class] nav .nav-link.active:hover {
  width: 100%;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px;
  flex: 0 0 44px;
  font-weight: 500 !important;
  overflow: hidden;
}

body > div > aside[class] nav .nav-link .nav-icon,
body > div > aside[class] nav .nav-link:hover .nav-icon,
body > div > aside[class] nav .nav-link.active .nav-icon {
  width: 20px !important;
  height: 20px !important;
  flex: 0 0 20px;
}

body > div > aside[class] nav .nav-link .nav-icon svg,
body > div > aside[class] nav .nav-link:hover .nav-icon svg,
body > div > aside[class] nav .nav-link.active .nav-icon svg {
  width: 20px !important;
  height: 20px !important;
  transform: none !important;
}

@media (min-width: 1024px) {
  body > div > aside[class] nav {
    scrollbar-gutter: stable;
    overflow-x: hidden;
    overflow-anchor: none;
  }
}

/* ── Tabelas e listas ── */
thead th {
  font-size: 0.875rem !important;
}

tbody td {
  font-size: var(--text-sm) !important;
}

.session-row {
  min-height: 52px;
}

.session-row,
.session-title,
.hist-title,
.hist-meta {
  font-size: var(--text-sm) !important;
}

/* ── Botões e campos: altura e tamanho mínimos ── */
.btn-primary,
.btn-ghost,
.btn-danger,
.btn-google {
  font-size: var(--text-sm) !important;
  min-height: 44px;
}

.field,
input.field,
select.field {
  font-size: var(--text-sm) !important;
  min-height: 44px;
}

/* ── Celular: texto base 16px e campos 16px (sem zoom no iPhone) ── */
@media (max-width: 1023px) {
  body {
    font-size: 16px !important;
  }

  main>header h1,
  #view-list>header h1 {
    font-size: 1.25rem !important;
  }

  main>header h1,
  #view-list>header h1 {
    font-size: 1.375rem !important;
  }

  input:not(.mm-box input),
  select:not(.mm-box select),
  textarea:not(.mm-box textarea) {
    font-size: 16px !important;
  }
}

/* ── Barra inferior do celular: todas as telas, rolagem para o lado ── */
@media (max-width: 1023px) {
  .app-bottomnav {
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .app-bottomnav::-webkit-scrollbar {
    display: none;
  }

  .app-bottomnav a {
    flex: 0 0 auto;
    width: 76px;
    scroll-snap-align: start;
  }
}

/* ── Simulados no celular ── */
@media (max-width: 767px) {
  /* Espaço para a barra inferior não cobrir o fim da página */
  main {
    padding: 1rem 1rem 7rem !important;
  }

  /* Cabeçalho: título e botões em coluna, botões ocupam a largura toda */
  main > header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  main > header > div:last-child {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  main > header > div:last-child > button {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Filtros: busca, níveis e órgãos em blocos organizados */
  .sim-toolbar-top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }

  .sim-levels {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0.5rem;
    padding-bottom: 2px;
  }

  .sim-levels::-webkit-scrollbar {
    display: none;
  }

  .sim-level {
    flex: 0 0 auto;
    min-height: 40px;
  }

  /* Lista de órgãos rola com o dedo; as setas ficam só no computador */
  .sim-toolbar-chips {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .sim-chips-wrap .sim-arrow {
    display: none !important;
  }

  .sim-chips {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .sim-chips::-webkit-scrollbar {
    display: none;
  }

  .sim-chips > * {
    scroll-snap-align: start;
    min-height: 40px;
  }

  .sim-toolbar-foot {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Catálogo em uma coluna */
  #sim-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }

  /* Histórico: cada linha quebra em duas partes se precisar */
  #sim-history .p-5 {
    padding: 1rem;
  }

  /* Prova: topo compacto */
  .exam-top-row {
    gap: 0.5rem;
  }

  /* Nome do órgão: uma linha só, que rola com o dedo */
  .exam-title,
  #exam-orgao,
  #result-orgao {
    font-size: 1.125rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .exam-title::-webkit-scrollbar,
  #exam-orgao::-webkit-scrollbar,
  #result-orgao::-webkit-scrollbar {
    display: none;
  }

  .exam-timer {
    font-size: 0.9375rem;
    padding: 0.375rem 0.625rem;
  }

  /* Pergunta vem antes; números das questões ficam abaixo */
  .exam-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .exam-question {
    padding: 1.125rem;
  }

  .exam-text {
    font-size: 1rem;
    line-height: 1.6;
  }

  .exam-options > * {
    min-height: 48px;
  }

  /* Botões Anterior e Próxima lado a lado, grandes para o dedo */
  .exam-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .exam-nav > button {
    justify-content: center;
    min-height: 48px;
  }

  /* Grade de números: mais colunas, cabe mais no celular */
  .exam-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)) !important;
    gap: 0.375rem;
  }

  .exam-grid > * {
    min-height: 40px;
  }

  /* Resultado: nota centralizada */
  .result-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.25rem;
    gap: 1rem;
  }

  .result-info {
    width: 100%;
  }

  .result-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .result-actions > button {
    width: 100%;
    justify-content: center;
  }

  .result-ring {
    width: 150px;
    height: 150px;
  }

  /* Cartões de números: dois por linha, com números menores */
  #view-result section.grid {
    gap: 0.5rem;
  }

  #view-result section.grid .text-3xl {
    font-size: 1.75rem !important;
  }

  /* Gabarito: abas em linha que rola, cabeçalho em coluna */
  #view-result section.card > div:first-child {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  #view-result [role="tablist"] {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #view-result [role="tablist"]::-webkit-scrollbar {
    display: none;
  }

  #view-result [role="tablist"] .tab {
    flex: 0 0 auto;
    min-height: 40px;
  }
}
