/* ==========================================================================
   Portal do Aluno — design system próprio
   Mobile-first, sem Bootstrap. Pensado para rodar em modo standalone (PWA),
   onde não existe barra do navegador e as safe areas do aparelho importam.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Cor da escola — pode ser sobrescrita inline por unidade */
  --marca:        #358485;
  --marca-forte:  #266466;
  --marca-suave:  #e6f2f2;

  --azul:    #2563eb;  --azul-suave:    #eff6ff;
  --verde:   #16a34a;  --verde-suave:   #dcfce7;
  --ambar:   #d97706;  --ambar-suave:   #fef3c7;
  --vermelho:#dc2626;  --vermelho-suave:#fee2e2;
  --roxo:    #9333ea;  --roxo-suave:    #f3e8ff;

  /* Superfícies e texto */
  --fundo:        #f4f6f8;
  --superficie:   #ffffff;
  --superficie-2: #f8fafc;
  --borda:        #e5e9ef;
  --texto:        #1a2332;
  --texto-2:      #5c6b80;
  --texto-3:      #94a3b8;

  --raio:    16px;
  --raio-sm: 10px;
  --raio-lg: 24px;

  --sombra:    0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sombra-md: 0 4px 12px rgba(16, 24, 40, .08);
  --sombra-lg: 0 12px 32px rgba(16, 24, 40, .14);

  --altura-header: 56px;
  --altura-tabbar: 62px;

  /* Recortes do aparelho (notch / barra inferior) */
  --safe-topo:  env(safe-area-inset-top, 0px);
  --safe-baixo: env(safe-area-inset-bottom, 0px);

  --fonte: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
           "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo:        #0f1620;
    --superficie:   #17202c;
    --superficie-2: #1e2836;
    --borda:        #2a3646;
    --texto:        #e8edf4;
    --texto-2:      #9aabc0;
    --texto-3:      #64748b;
    --marca-suave:  #16302f;

    --azul-suave: #16243d; --verde-suave: #12301f;
    --ambar-suave:#33260c; --vermelho-suave:#3a1a1a;
    --roxo-suave: #2a1a3d;

    --sombra:    0 1px 2px rgba(0,0,0,.3);
    --sombra-md: 0 4px 12px rgba(0,0,0,.4);
    --sombra-lg: 0 12px 32px rgba(0,0,0,.5);
  }
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--fonte);
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto);
  background: var(--fundo);
  -webkit-font-smoothing: antialiased;
  /* Evita seleção acidental em toque longo, como app nativo */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Campos precisam continuar selecionáveis */
input, textarea, select { -webkit-user-select: text; user-select: text; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.02em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p  { margin: 0 0 .75rem; }
a  { color: var(--marca); text-decoration: none; }

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

/* --------------------------------------------------------------------------
   3. Estrutura do app
   -------------------------------------------------------------------------- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(var(--altura-header) + var(--safe-topo));
  padding: var(--safe-topo) 16px 0;
  background: color-mix(in srgb, var(--superficie) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--borda);
}

.app-header h1 {
  font-size: 1.0625rem;
  font-weight: 650;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-conteudo {
  flex: 1;
  padding: 16px;
  /* Espaço para a tabbar não cobrir o final da página */
  padding-bottom: calc(var(--altura-tabbar) + var(--safe-baixo) + 24px);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

/* Botão redondo do header */
.icone-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--texto-2);
  font-size: 1.35rem;
  cursor: pointer;
  transition: background .15s;
}
.icone-btn:active { background: var(--superficie-2); }

/* --------------------------------------------------------------------------
   4. Tab bar
   -------------------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  height: calc(var(--altura-tabbar) + var(--safe-baixo));
  padding-bottom: var(--safe-baixo);
  background: color-mix(in srgb, var(--superficie) 90%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--borda);
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--texto-3);
  font-size: .6875rem;
  font-weight: 550;
  position: relative;
  /* Alvo de toque confortável */
  min-height: 44px;
  transition: color .15s;
}

.tabbar a i { font-size: 1.375rem; }
.tabbar a.ativo { color: var(--marca); }

/* Traço indicando a aba ativa */
.tabbar a.ativo::before {
  content: '';
  position: absolute;
  top: 0;
  width: 26px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--marca);
}

.tabbar .selo {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--vermelho);
  color: #fff;
  font-size: .625rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   5. Cartões
   -------------------------------------------------------------------------- */
.cartao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  overflow: hidden;
}

.cartao + .cartao { margin-top: 12px; }
.cartao-corpo { padding: 16px; }

.cartao-topo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--borda);
}
.cartao-topo h3 { flex: 1; }

/* Cartão de destaque com a cor da escola */
.cartao-marca {
  background: linear-gradient(135deg, var(--marca), var(--marca-forte));
  color: #fff;
  border: 0;
}
.cartao-marca h1, .cartao-marca h2, .cartao-marca h3 { color: #fff; }
.cartao-marca .rotulo { color: rgba(255,255,255,.75); }

/* --------------------------------------------------------------------------
   6. Listas
   -------------------------------------------------------------------------- */
.lista { display: flex; flex-direction: column; }

.lista-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  color: inherit;
  background: var(--superficie);
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: background .15s;
}
.lista-item + .lista-item { border-top: 1px solid var(--borda); }
.lista-item:active { background: var(--superficie-2); }

.lista-item .avatar-icone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 11px;
  background: var(--marca-suave);
  color: var(--marca);
  font-size: 1.25rem;
}

.lista-item .conteudo { flex: 1; min-width: 0; }
.lista-item .titulo {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lista-item .sub {
  font-size: .8125rem;
  color: var(--texto-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lista-item .seta { color: var(--texto-3); font-size: 1.25rem; flex-shrink: 0; }

/* Variações de cor do ícone */
.avatar-icone.azul   { background: var(--azul-suave);   color: var(--azul); }
.avatar-icone.verde  { background: var(--verde-suave);  color: var(--verde); }
.avatar-icone.ambar  { background: var(--ambar-suave);  color: var(--ambar); }
.avatar-icone.vermelho{background: var(--vermelho-suave);color: var(--vermelho); }
.avatar-icone.roxo   { background: var(--roxo-suave);   color: var(--roxo); }

/* --------------------------------------------------------------------------
   7. Atalhos (grade da home)
   -------------------------------------------------------------------------- */
.atalhos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 380px) {
  .atalhos { grid-template-columns: repeat(3, 1fr); }
}

.atalho {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 6px;
  border-radius: var(--raio);
  background: var(--superficie);
  border: 1px solid var(--borda);
  color: var(--texto);
  font-size: .75rem;
  font-weight: 550;
  text-align: center;
  line-height: 1.2;
  transition: transform .12s, box-shadow .12s;
}
.atalho:active { transform: scale(.96); }
.atalho i { font-size: 1.5rem; color: var(--marca); }

/* --------------------------------------------------------------------------
   8. Selos de status
   -------------------------------------------------------------------------- */
.selo-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.selo-status.ok       { background: var(--verde-suave);    color: var(--verde); }
.selo-status.pendente { background: var(--ambar-suave);    color: var(--ambar); }
.selo-status.atrasado { background: var(--vermelho-suave); color: var(--vermelho); }
.selo-status.info     { background: var(--azul-suave);     color: var(--azul); }
.selo-status.neutro   { background: var(--superficie-2);   color: var(--texto-2); }
.selo-status.roxo     { background: var(--roxo-suave);     color: var(--roxo); }

/* --------------------------------------------------------------------------
   9. Botões
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 20px;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, opacity .15s;
  text-align: center;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-principal { background: var(--marca); color: #fff; }
.btn-secundario{ background: var(--superficie); color: var(--texto); border-color: var(--borda); }
.btn-fantasma  { background: transparent; color: var(--marca); }
.btn-perigo    { background: var(--vermelho); color: #fff; }
.btn-bloco     { display: flex; width: 100%; }
.btn-sm        { padding: 8px 14px; min-height: 38px; font-size: .8125rem; }

/* --------------------------------------------------------------------------
   10. Formulários
   -------------------------------------------------------------------------- */
.campo { margin-bottom: 14px; }

.campo label {
  display: block;
  margin-bottom: 6px;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--texto-2);
}

.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 12px 14px;
  /* 16px evita o zoom automático do iOS ao focar */
  font-size: 16px;
  font-family: inherit;
  color: var(--texto);
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.campo input:focus, .campo select:focus, .campo textarea:focus {
  border-color: var(--marca);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--marca) 18%, transparent);
}

.campo .ajuda { margin-top: 5px; font-size: .75rem; color: var(--texto-3); }

/* --------------------------------------------------------------------------
   11. Utilidades
   -------------------------------------------------------------------------- */
.secao-titulo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 2px 10px;
}
.secao-titulo h2 { font-size: .9375rem; font-weight: 650; }
.secao-titulo a  { font-size: .8125rem; font-weight: 600; }
.app-conteudo > .secao-titulo:first-child { margin-top: 4px; }

.rotulo {
  font-size: .6875rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--texto-3);
}

.valor-grande { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }

.vazio { padding: 44px 20px; text-align: center; color: var(--texto-2); }
.vazio i { font-size: 2.75rem; color: var(--texto-3); display: block; margin-bottom: 10px; }
.vazio p { margin: 0; font-size: .875rem; }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.linha { display: flex; align-items: center; gap: 10px; }
.entre { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cresce { flex: 1; min-width: 0; }
.pilha  { display: flex; flex-direction: column; gap: 12px; }

.t-2 { color: var(--texto-2); }
.t-3 { color: var(--texto-3); }
.t-sm{ font-size: .8125rem; }
.t-xs{ font-size: .75rem; }
.negrito { font-weight: 650; }
.centro  { text-align: center; }

/* --------------------------------------------------------------------------
   11b. Chips / filtros
   -------------------------------------------------------------------------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  /* Some a barra de rolagem sem perder o gesto de arrastar */
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 15px;
  border: 1px solid var(--borda);
  border-radius: 999px;
  background: var(--superficie);
  color: var(--texto-2);
  font: inherit;
  font-size: .8125rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.chip.ativo {
  background: var(--marca);
  border-color: var(--marca);
  color: #fff;
}

/* --------------------------------------------------------------------------
   11c. Telas públicas (login, recuperação)
   -------------------------------------------------------------------------- */
.tela-auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(28px + var(--safe-topo)) 20px calc(28px + var(--safe-baixo));
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
}

.auth-marca { text-align: center; margin-bottom: 26px; }
.auth-marca img { max-height: 76px; width: auto; }
.auth-marca .nome { margin-top: 12px; font-size: 1.25rem; font-weight: 650; }
.auth-marca .sub  { font-size: .875rem; color: var(--texto-2); margin-top: 2px; }

/* Alternador aluno / responsável */
.segmento {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: var(--superficie-2);
  border: 1px solid var(--borda);
  border-radius: 13px;
}

.segmento label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--texto-2);
  cursor: pointer;
  transition: background .18s, color .18s;
}

.segmento input { position: absolute; opacity: 0; pointer-events: none; }
.segmento input:checked + span {
  position: absolute;
  inset: 0;
}
.segmento label:has(input:checked) {
  background: var(--superficie);
  color: var(--marca);
  box-shadow: var(--sombra);
}

/* Fallback para navegador sem :has() */
.segmento label.marcado {
  background: var(--superficie);
  color: var(--marca);
  box-shadow: var(--sombra);
}

/* Campo de senha com botão de revelar */
.campo-senha { position: relative; }
.campo-senha input { padding-right: 46px; }
.campo-senha .olho {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--texto-3);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Caixa de código de 6 dígitos */
.campo-codigo input {
  letter-spacing: .55em;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 650;
  padding-left: .55em;
}

.aviso {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: .8125rem;
  margin-bottom: 14px;
}
.aviso.erro    { background: var(--vermelho-suave); color: var(--vermelho); }
.aviso.ok      { background: var(--verde-suave);    color: var(--verde); }
.aviso.atencao { background: var(--ambar-suave);    color: var(--ambar); }

/* --------------------------------------------------------------------------
   11d. Calendário
   -------------------------------------------------------------------------- */
.cal-grade {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-cab {
  text-align: center;
  font-size: .6875rem;
  font-weight: 650;
  color: var(--texto-3);
  text-transform: uppercase;
  padding: 4px 0 6px;
}

.cal-dia {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--texto);
  font: inherit;
  font-size: .875rem;
  cursor: pointer;
  /* Alvo de toque mínimo mesmo em tela estreita */
  min-height: 40px;
}

.cal-dia.fora     { color: var(--texto-3); opacity: .45; }
.cal-dia.hoje     { font-weight: 700; color: var(--marca); }
.cal-dia.selecionado { background: var(--marca); color: #fff; }
.cal-dia.selecionado .pontos i { background: #fff !important; }

.cal-dia .pontos { display: flex; gap: 2px; height: 4px; }
.cal-dia .pontos i { width: 4px; height: 4px; border-radius: 50%; display: block; }

.ponto-aula       { background: var(--marca); }
.ponto-feriado    { background: var(--vermelho); }
.ponto-recesso    { background: var(--ambar); }
.ponto-comunicado { background: var(--azul); }

/* --------------------------------------------------------------------------
   11e. Carteirinha
   -------------------------------------------------------------------------- */
.carteirinha {
  border-radius: var(--raio-lg);
  overflow: hidden;
  box-shadow: var(--sombra-lg);
  background: linear-gradient(150deg, var(--marca), var(--marca-forte));
  color: #fff;
}

.cart-topo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 0;
}
.cart-topo img { height: 26px; width: auto; filter: brightness(0) invert(1); opacity: .95; }
.cart-topo .escola { font-size: .8125rem; font-weight: 650; letter-spacing: .02em; }

.cart-corpo {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}

.cart-foto {
  width: 78px; height: 78px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.15);
}

.cart-nome { font-size: 1.0625rem; font-weight: 700; line-height: 1.2; }
.cart-linha { font-size: .8125rem; opacity: .85; margin-top: 3px; }

.cart-rodape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  background: rgba(0, 0, 0, .16);
  font-size: .75rem;
}
.cart-codigo {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .08em;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   12. Carregamento
   -------------------------------------------------------------------------- */
.esqueleto {
  background: linear-gradient(90deg, var(--superficie-2) 25%, var(--borda) 37%, var(--superficie-2) 63%);
  background-size: 400% 100%;
  animation: brilho 1.3s ease infinite;
  border-radius: 8px;
}
@keyframes brilho { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.girando {
  width: 22px; height: 22px;
  border: 2.5px solid var(--borda);
  border-top-color: var(--marca);
  border-radius: 50%;
  animation: girar .7s linear infinite;
  display: inline-block;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   13. Bottom sheet
   -------------------------------------------------------------------------- */
.sheet-fundo {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 15, 25, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.sheet-fundo.aberto { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 101;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 8px 18px calc(20px + var(--safe-baixo));
  background: var(--superficie);
  border-radius: var(--raio-lg) var(--raio-lg) 0 0;
  box-shadow: var(--sombra-lg);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
}
.sheet.aberto { transform: translateY(0); }

/* Puxador visual do sheet */
.sheet::before {
  content: '';
  display: block;
  width: 38px; height: 4px;
  margin: 6px auto 14px;
  border-radius: 2px;
  background: var(--borda);
}

/* --------------------------------------------------------------------------
   14. Desktop
   -------------------------------------------------------------------------- */
@media (min-width: 900px) {
  body { background: var(--fundo); }

  .app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    box-shadow: 0 0 0 1px var(--borda);
    background: var(--fundo);
  }

  .tabbar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
