/* Estilos do app, iguais nos dois hospedeiros (BlazorWebView do app MAUI e PWA).
   As medidas vêm do app em XAML: 1 unidade do MAUI = 1px aqui. */

@font-face {
  font-family: "Open Sans";
  font-weight: 400;
  font-display: swap;
  src: url("fontes/OpenSans-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "Open Sans";
  font-weight: 600;
  font-display: swap;
  src: url("fontes/OpenSans-Semibold.ttf") format("truetype");
}

/* ===== Cores =====
   Paleta neutra e provisória: a identidade visual do projeto ainda não foi definida.
   Ao trocar --primaria, atualize também o theme-color dos index.html e do manifesto do PWA,
   e Platforms/Android/Resources/values/colors.xml no app. */
:root {
  color-scheme: light dark;

  /* Azul-ardósia. Branco sobre ele: contraste 8,6:1. */
  --primaria: #334e68;
  --sobre-primaria: #ffffff;
  --fundo: #ffffff;
  --texto: #000000;
  --texto-forte: #212121;
  --texto-secundario: #6e6e6e;
  --texto-rotulo: #404040;
  --borda: #c8c8c8;
  --borda-forte: #919191;

  /* Fundo de cartões e faixas de aviso. */
  --superficie: #f1f4f7;
  --selo-fundo: #d9e2ec;
  --selo-texto: #243b53;
  --erro: #b42318;
  --sucesso: #067647;
  --aviso: #93370d;
  --desabilitado-fundo: #e1e1e1;
  --desabilitado-texto: #404040;
  --abas-fundo: #ffffff;
  --aba-atual: #334e68;
  --aba-outra: #6e6e6e;
  --sombra: rgb(0 0 0 / 45%);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Versão clara da primária, com texto escuro por cima (6,8:1). */
    --primaria: #9fb3c8;
    --sobre-primaria: #102a43;
    --fundo: #1f1f1f;
    --texto: #ffffff;
    --texto-forte: #ffffff;
    --texto-secundario: #acacac;
    --texto-rotulo: #c8c8c8;
    --borda: #6e6e6e;
    --borda-forte: #acacac;
    --superficie: #2b2b2b;
    --selo-fundo: #404040;
    --selo-texto: #ffffff;
    --erro: #fda29b;
    --sucesso: #75e0a7;
    --aviso: #fec84b;
    --desabilitado-fundo: #404040;
    --desabilitado-texto: #acacac;
    --abas-fundo: #000000;
    --aba-atual: #ffffff;
    --aba-outra: #919191;
    --sombra: rgb(0 0 0 / 65%);
  }
}

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

html,
body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: var(--fundo);
  color: var(--texto);
  font-family: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

p,
h1,
h2,
h3 {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  overflow-wrap: anywhere;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  touch-action: manipulation;

  /* Segurar o dedo num botão não seleciona o texto dele. */
  -webkit-user-select: none;
  user-select: none;
}

:focus-visible {
  outline: 2px solid var(--primaria);
  outline-offset: 2px;
}

/* ===== Estrutura: telas empilhadas, abas embaixo ===== */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.telas {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* Todas as telas abertas ficam montadas; só a de cima da aba atual aparece. As outras guardam o que
   tinham (campos, rolagem) para quando a pessoa voltar. */
.tela {
  position: absolute;
  inset: 0;
  background: var(--fundo);
}

.tela[inert] {
  visibility: hidden;
}

.abertura {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.pagina {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.barra {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top) max(4px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  color: var(--texto-forte);
}

.barra-voltar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-left: -12px;
  border: 0;
  border-radius: 24px;
  background: transparent;
  cursor: pointer;
}

.barra-titulo {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.barra-acoes {
  display: flex;
  align-items: center;
}

.barra-acao {
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--primaria);
  font-weight: 600;
  cursor: pointer;
}

.barra-acao:disabled {
  color: var(--texto-secundario);
  cursor: default;
}

.pagina-topo,
.pagina-rodape {
  flex: none;
}

.pagina-corpo {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pagina-corpo.estreita > * {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.abas {
  flex: none;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--borda);
  background: var(--abas-fundo);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.aba {
  flex: 1;
  max-width: 168px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--aba-outra);
  font-size: 12px;
  cursor: pointer;
}

.aba-atual {
  color: var(--aba-atual);
  font-weight: 600;
}

.aba-icone {
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  mask-repeat: no-repeat;
}

/* ===== Arranjo ===== */
.pilha {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.linha {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.grade {
  display: grid;
  min-width: 0;
}

.grade > * {
  min-width: 0;
}

/* Mensagem no meio da área de rolagem ("Nenhum aluno encontrado."). */
.vazio {
  padding: 32px;
  text-align: center;
  color: var(--texto-secundario);
  font-size: 13px;
}

.centralizado {
  text-align: center;
}

/* ===== Texto ===== */
.titulo-pagina {
  font-size: 24px;
  font-weight: 600;
  color: var(--texto-forte);
}

.titulo-secao {
  margin-top: 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--texto-forte);
}

.titulo-item {
  font-size: 16px;
  font-weight: 600;
}

.rotulo {
  font-size: 13px;
  font-weight: 600;
  color: var(--texto-rotulo);
}

.secundario {
  font-size: 13px;
  color: var(--texto-secundario);
}

.erro {
  font-size: 13px;
  color: var(--erro);
  white-space: pre-line;
}

.sucesso {
  font-size: 14px;
  color: var(--sucesso);
}

/* Texto que vem dos dados e pode trazer quebras de linha. Escreva o valor colado nas tags:
   <p class="multilinha">@Vm.Texto</p>. */
.multilinha {
  white-space: pre-line;
}

/* Uma linha só, com reticências no fim. */
.cortar {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Botões ===== */
.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  min-width: 48px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primaria);
  color: var(--sobre-primaria);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.botao.inicio {
  width: auto;
  align-self: flex-start;
  justify-self: start;
}

.botao.secundario {
  background: transparent;
  color: var(--primaria);
  border-color: var(--primaria);
}

.botao.texto {
  background: transparent;
  color: var(--primaria);
}

.botao.perigo {
  background: transparent;
  color: var(--erro);
  border-color: var(--erro);
}

.botao:disabled {
  background: var(--desabilitado-fundo);
  color: var(--desabilitado-texto);
  border-color: transparent;
  cursor: default;
}

.botao.texto:disabled {
  background: transparent;
  color: var(--texto-secundario);
}

/* ===== Cartões e selos ===== */
.cartao {
  display: block;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--superficie);
}

.cartao-toque {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.cartao-alerta {
  border: 1px solid var(--erro);
}

.aviso-erro {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 16px;
}

.faixa-sincronizacao {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 16px;
  padding: 4px 12px;
}

/* Etiqueta pequena ("Pagante", "Inativo", "Senha pendente"). */
.selo {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--selo-fundo);
  color: var(--selo-texto);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* Etiqueta que pede atenção ("Inadimplente", "Vencida"). */
.selo-alerta {
  background: transparent;
  border-color: var(--erro);
  color: var(--erro);
}

/* ===== Campos ===== */
.campo {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.linha-dado {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.entrada,
.seletor {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--borda-forte);
  border-radius: 8px;
  background: transparent;
  color: var(--texto);
  font-size: 16px;
}

.entrada::placeholder {
  color: var(--texto-secundario);
  opacity: 1;
}

.entrada:disabled,
.seletor:disabled {
  color: var(--texto-secundario);
  border-color: var(--borda);
}

.entrada-longa {
  display: block;
  resize: vertical;
  field-sizing: content;
  min-height: 84px;
  line-height: 1.35;
}

.seletor {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23919191' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
  text-overflow: ellipsis;
}

.seletor option {
  background: var(--fundo);
  color: var(--texto);
}

/* Liga/desliga */
.interruptor {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 48px;
  cursor: pointer;
}

.interruptor input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.interruptor-trilho {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--borda);
  transition: background-color 0.15s;
}

.interruptor-trilho::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 40%);
  transition: transform 0.15s;
}

.interruptor input:checked + .interruptor-trilho {
  background: var(--primaria);
}

.interruptor input:checked + .interruptor-trilho::after {
  transform: translateX(20px);
}

.interruptor input:disabled + .interruptor-trilho {
  opacity: 0.5;
}

.interruptor input:focus-visible + .interruptor-trilho {
  outline: 2px solid var(--primaria);
  outline-offset: 2px;
}

/* Caixa de marcar e opção de grupo, com o texto ao lado. */
.caixa {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  cursor: pointer;
}

.caixa input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0 2px;
  accent-color: var(--primaria);
  cursor: pointer;
}

/* ===== Indicador de atividade ===== */
.carregando {
  display: flex;
  justify-content: center;
  padding: 8px;
}

.carregando.no-centro {
  position: absolute;
  inset: 0;
  align-items: center;
  pointer-events: none;
}

.carregando-roda {
  width: 28px;
  height: 28px;
  border: 3px solid var(--borda);
  border-top-color: var(--primaria);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}

@keyframes girar {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Foto do aluno ===== */
.foto-do-aluno {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: 48px;
  overflow: hidden;
  background: var(--selo-fundo);
  color: var(--primaria);
  font-size: 32px;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .foto-do-aluno {
    color: #ffffff;
  }
}

.foto-do-aluno img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.foto-do-aluno-ocupado {
  position: absolute;
  inset: 0;
  align-items: center;
}

/* ===== Diálogos ===== */
.dialogo-fundo {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--sombra);
}

.dialogo {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 20px 8px;
  border-radius: 14px;
  background: var(--fundo);
  box-shadow: 0 8px 32px rgb(0 0 0 / 30%);
}

.dialogo-titulo {
  font-size: 18px;
  font-weight: 600;
  color: var(--texto-forte);
}

.dialogo-opcoes {
  margin: 0 -8px;
}

.dialogo-opcao {
  min-height: 48px;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.dialogo-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

/* ===== Aviso de falha do próprio Blazor ===== */
#blazor-error-ui {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #fff3cd;
  color: #212121;
  font-size: 14px;
}

#blazor-error-ui .reload {
  margin-left: 8px;
  color: #334e68;
  font-weight: 600;
}

#blazor-error-ui .dismiss {
  float: right;
  cursor: pointer;
}
