/* ==========================================================================
   Intranet Marillac — módulo Alunos (lista e ficha)
   ========================================================================== */

@property --p { syntax: '<number>'; inherits: true; initial-value: 0; }

:root {
  --s-acima: #15803D; --s-acima-bg: #E7F6EC;
  --s-na: #B45309; --s-na-bg: #FEF3E2;
  --s-abaixo: #BE123C; --s-abaixo-bg: #FDE8EE;
  --s-sem: #64748B; --s-sem-bg: #EEF1F6;
}

/* ---------- Filtros ---------- */
.al-filtros {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 12px 14px;
  padding: 16px 18px; align-items: end;
}
.al-filtros-ficha { grid-template-columns: repeat(auto-fit, minmax(170px, 240px)); }
.al-campo { display: grid; gap: 6px; min-width: 0; }
.al-campo > label, .al-campo .rotulo-campo { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.al-campo .entrada-texto { min-height: 42px; padding-top: 8px; padding-bottom: 8px; font-size: 14px; }
.al-busca { grid-column: span 2; }
.al-busca-wrap { position: relative; display: block; }
.al-busca-wrap .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.al-busca-wrap .entrada-texto { padding-left: 40px; }
.al-exib { display: inline-flex; justify-self: start; border: 1.5px solid var(--line-2); border-radius: 12px; overflow: hidden; height: 42px; }
.al-planilha { font-size: 12.5px; }
.al-exib button { width: 46px; border: 0; background: var(--surface); color: var(--muted); display: grid; place-items: center; transition: background .15s, color .15s; }
.al-exib button + button { border-left: 1.5px solid var(--line-2); }
.al-exib button[aria-pressed="true"] { background: var(--blue-50); color: var(--tx-forte); }
.al-exib button:hover .ic { transform: scale(1.15); transition: transform .2s var(--ease-mola); }

/* chips de rendimento (contagem + filtro rápido) */
.al-resumo { flex-wrap: wrap; }
.al-filtro-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); transition: border-color .15s, background .15s, transform .15s;
}
.al-filtro-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.al-filtro-chip strong { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.al-filtro-chip:hover { transform: translateY(-1px); border-color: var(--c); }
.al-filtro-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 10%, var(--surface)); border-color: var(--c); }
.al-filtro-chip.s-acima { --c: var(--s-acima); } .al-filtro-chip.s-na { --c: var(--s-na); }
.al-filtro-chip.s-abaixo { --c: var(--s-abaixo); } .al-filtro-chip.s-sem { --c: var(--s-sem); }

/* ---------- Situação ---------- */
.al-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; vertical-align: middle;
}
.al-chip.s-acima { background: var(--s-acima-bg); color: var(--s-acima); }
.al-chip.s-na { background: var(--s-na-bg); color: var(--s-na); }
.al-chip.s-abaixo { background: var(--s-abaixo-bg); color: var(--s-abaixo); }
.al-chip.s-sem { background: var(--s-sem-bg); color: var(--s-sem); }

/* ---------- Avatar com anel de progresso (média × 10%) ---------- */
.al-avatar {
  --tam: 58px; --c: var(--s-sem);
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--tam); height: var(--tam); border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--trilho) 0);
  animation: anel-encher 1.1s var(--ease) both;
}
.al-avatar.s-acima { --c: var(--s-acima); } .al-avatar.s-na { --c: #E08A1E; } .al-avatar.s-abaixo { --c: var(--s-abaixo); }
@keyframes anel-encher { from { --p: 0; } }
.al-avatar-in {
  position: relative; width: calc(100% - 7px); height: calc(100% - 7px); border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: var(--surface);
}
.al-ini {
  width: 100%; height: 100%; display: grid; place-items: center; font-weight: 800; font-size: calc(var(--tam) * .3);
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, var(--surface));
}
.al-foto { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: foto-surge .5s ease both; }
@keyframes foto-surge { from { opacity: 0; transform: scale(1.08); } }
.al-avatar.pequeno { --tam: 40px; }
.al-avatar.grande { --tam: 84px; }

/* ---------- Cartões ---------- */
.al-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }
.al-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 18px 14px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  color: inherit; text-decoration: none; box-shadow: var(--sombra-sm);
  transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
  animation: card-entra .5s var(--ease) backwards; animation-delay: calc(var(--i) * 22ms);
}
@keyframes card-entra { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.al-card::before { /* brilho que segue a cor da situação */
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .3s;
  background: radial-gradient(180px 120px at 50% 0%, color-mix(in srgb, var(--c, var(--navy-500)) 14%, transparent), transparent 70%);
}
.al-card.s-acima { --c: var(--s-acima); } .al-card.s-na { --c: #E08A1E; } .al-card.s-abaixo { --c: var(--s-abaixo); } .al-card.s-sem { --c: var(--s-sem); }
.al-card::after { /* faixa de luz no hover */
  content: ''; position: absolute; top: 0; bottom: 0; width: 45%; left: -70%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .7), transparent); transform: skewX(-18deg);
}
.al-card:hover, .al-card:focus-visible { transform: translateY(-4px); box-shadow: 0 18px 34px -18px rgba(27, 42, 107, .45); border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }
.al-card:hover::before, .al-card:focus-visible::before { opacity: 1; }
.al-card:hover::after { left: 130%; transition: left .8s var(--ease); }
.al-card:hover .al-avatar { animation: anel-pulsa .9s var(--ease-mola); }
@keyframes anel-pulsa { 40% { transform: scale(1.08); } }
.al-card .al-avatar { margin-bottom: 8px; }
.al-nome {
  font-size: 14px; font-weight: 800; color: var(--tx-titulo); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em;
}
.al-turma { font-size: 12px; color: var(--muted); }
.al-turma em { font-style: normal; font-weight: 700; color: var(--s-na); }
.al-turma em.sem-turma { color: var(--s-sem); }
.al-conferencia { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.al-conferencia .ic { color: var(--ok); }
.al-metricas { width: 100%; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: grid; gap: 5px; }
.al-metricas div { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; }
.al-metricas dt { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.al-metricas dt .ic { width: 14px; height: 14px; color: var(--navy-500); transition: transform .3s var(--ease-mola); }
.al-metricas dd { margin: 0; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.al-metricas dd.baixa { color: var(--s-abaixo); }
.al-card:hover .al-metricas dt .ic { transform: translateY(-2px) rotate(-8deg); }
.al-spark-wrap { width: 100%; height: 26px; margin-top: 6px; }
.al-rodape { width: 100%; margin-top: 8px; padding-top: 9px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.al-ir { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--tx-forte); transition: transform .25s var(--ease-mola), background .2s; }
.al-card:hover .al-ir { transform: translateX(3px); background: var(--blue-50); }
.al-mais { display: flex; margin: 18px auto 0; }

/* mini linha (desenha-se) */
.al-spark { width: 100%; height: 26px; overflow: visible; }
.al-spark path { fill: none; stroke: var(--navy-500); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: traco 1.1s var(--ease) .25s forwards; }
.al-spark.desce path { stroke: #E8622C; }
.al-spark circle { fill: #fff; stroke: var(--navy-500); stroke-width: 2; opacity: 0; animation: ponto .3s ease 1.2s forwards; }
.al-spark.desce circle { stroke: #E8622C; }
.al-spark .corte { stroke: rgba(190, 18, 60, .25); stroke-width: 1; stroke-dasharray: 3 3; }
@keyframes traco { to { stroke-dashoffset: 0; } }
@keyframes ponto { to { opacity: 1; } }
.al-tabela .al-spark { width: 90px; }
.al-linha { animation: card-entra .4s var(--ease) backwards; animation-delay: calc(var(--i) * 15ms); }

/* ---------- Ficha: trilha e cabeçalho ---------- */
.al-trilha { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.al-trilha a { color: var(--tx-forte); font-weight: 600; text-decoration: none; }
.al-trilha a:hover { text-decoration: underline; }
.al-trilha .ic { color: var(--line-2); }
.al-trilha span[aria-current] { font-weight: 700; color: var(--ink); }
.al-cabecalho { position: relative; overflow: hidden; display: flex; align-items: center; gap: 20px; padding: 20px 24px; }
.al-cabecalho::after { /* listras da marca no canto */
  content: ''; position: absolute; top: 0; bottom: 0; right: -30px; width: 260px; pointer-events: none; opacity: .14;
  background: linear-gradient(115deg, transparent 0 34%, #E8622C 34% 38%, transparent 38% 42%, #8DB4E2 42% 52%, #4E63B5 52% 60%, transparent 60%);
}
.al-cab-texto { min-width: 0; flex: 1; }
.al-cab-texto h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; color: var(--tx-titulo); letter-spacing: -.02em; }
.al-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.al-meta span { display: inline-flex; align-items: center; gap: 6px; }
.al-meta .ic { color: var(--navy-500); }
.al-meta u { text-decoration-style: dotted; text-underline-offset: 3px; }
.al-ver-turma { position: relative; z-index: 1; }

/* abas com indicador deslizante */
.al-abas { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; }
.al-aba {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  font-size: 14px; font-weight: 700; color: var(--muted); text-decoration: none; white-space: nowrap; border-radius: 10px 10px 0 0;
  transition: color .2s, background .2s;
}
.al-aba:hover { color: var(--tx-forte); background: rgba(255, 255, 255, .6); }
.al-aba.ativa { color: var(--tx-forte); }
.al-aba .ic { transition: transform .35s var(--ease-mola); }
.al-aba:hover .ic, .al-aba.ativa .ic { transform: scale(1.18) rotate(-6deg); color: var(--orange-500); }
.al-abas-indicador {
  position: absolute; left: 0; bottom: -1px; height: 3px; width: 0; border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--navy-600), var(--orange-500));
  transition: transform .4s var(--ease), width .4s var(--ease);
  box-shadow: 0 0 10px rgba(232, 98, 44, .5);
}
#al-aba { display: grid; gap: 20px; }
#al-aba.entrando > * { animation: subir .45s var(--ease) backwards; }
#al-aba.entrando > *:nth-child(2) { animation-delay: .06s; }
#al-aba.entrando > *:nth-child(3) { animation-delay: .12s; }

/* ---------- KPIs da ficha ---------- */
.al-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.al-kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.al-kpi { display: flex; gap: 14px; align-items: flex-start; }
.al-kpi .valor { color: var(--kc); font-size: 30px; }
.al-kpi .valor small { color: var(--muted); }
.al-kpi-ic {
  position: relative; width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center;
  color: var(--kc); background: color-mix(in srgb, var(--kc) 12%, var(--surface));
}
.al-kpi-ic::after { content: ''; position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--kc); opacity: 0; animation: halo 3.2s ease-out infinite; }
.al-kpi:nth-child(2) .al-kpi-ic::after { animation-delay: .8s; }
.al-kpi:nth-child(3) .al-kpi-ic::after { animation-delay: 1.6s; }
.al-kpi:nth-child(4) .al-kpi-ic::after { animation-delay: 2.4s; }
.al-kpi:hover .al-kpi-ic .ic { animation: ic-pulo .7s var(--ease-mola); }
.al-kpi .rotulo-kpi { font-size: 12.5px; }

/* ---------- Grade da ficha ---------- */
.al-grade-ficha { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.al-grade-ficha.al-estreita { grid-template-columns: minmax(0, 1fr) 280px; }
.al-estreita .al-disc { white-space: normal; max-width: 190px; line-height: 1.25; }
.al-estreita .tabela { font-size: 13.5px; }
.al-col-principal, .al-col-lateral { display: grid; gap: 20px; min-width: 0; }
/* itens de grade não podem crescer até a largura da tabela: a tabela rola dentro do cartão */
.al-col-principal > *, .al-col-lateral > *, .al-grade-ficha > * { min-width: 0; }
.al-notas th, .al-notas td, .al-freq th, .al-freq td { padding-left: 10px; padding-right: 10px; }
.al-notas th:first-child, .al-notas td:first-child, .al-freq th:first-child, .al-freq td:first-child { padding-left: 24px; }
.link-acao { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--tx-forte); text-decoration: none; }
.link-acao .ic { transition: transform .2s var(--ease); }
.link-acao:hover .ic { transform: translateX(3px); }
.legenda .tracejado { background: none; border-top: 2px dashed rgba(192, 38, 75, .6); height: 0; border-radius: 0; }
.al-dl { margin: 0; display: grid; }
.al-dl div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.al-dl div:last-child { border-bottom: 0; }
.al-dl dt { color: var(--muted); }
.al-dl dd { margin: 0; font-weight: 700; color: var(--ink); text-align: right; }
.al-dl dd a { display: inline-flex; align-items: center; gap: 2px; color: var(--tx-forte); text-decoration: none; }

/* rosca */
.al-donut-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.al-donut { position: relative; height: 180px; min-width: 0; }
.al-donut canvas, .grafico canvas { max-width: 100%; }
.al-donut-centro { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.al-donut-centro strong { font-size: 30px; font-weight: 800; color: var(--tx-titulo); line-height: 1; animation: subir .6s var(--ease) .5s backwards; }
.al-donut-centro span { font-size: 11.5px; color: var(--muted); }
.al-legenda { list-style: none; margin: 0; padding: 0; display: grid; }
.al-legenda li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.al-legenda li:last-child { border-bottom: 0; }
.al-legenda i { width: 10px; height: 10px; border-radius: 50%; }
.al-legenda strong { margin-left: auto; color: var(--ink); }

/* média geral (Notas) */
.al-media-grande { display: grid; justify-items: center; gap: 8px; padding: 18px; border-radius: 14px; background: var(--blue-50); }
.al-media-grande strong { font-size: 46px; font-weight: 800; line-height: 1; color: var(--tx-forte); font-variant-numeric: tabular-nums; }
.al-media-card.s-abaixo .al-media-grande { background: var(--s-abaixo-bg); }
.al-media-card.s-abaixo .al-media-grande strong { color: var(--s-abaixo); }

/* ---------- Tabelas da ficha ---------- */
.al-notas td, .al-freq td { padding-top: 10px; padding-bottom: 10px; }
.al-notas tbody tr, .al-freq tbody tr { animation: card-entra .35s var(--ease) backwards; animation-delay: calc(var(--i) * 18ms); }
.al-notas tr.al-nova-disc td { border-top: 1px solid var(--line-2); }
.al-notas tr:not(.al-nova-disc) td { border-top: 0; }
.al-disc { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--tx-forte); white-space: nowrap; }
.al-sigla {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none;
  font-size: 10.5px; font-weight: 800; color: hsl(var(--h) 55% 35%); background: hsl(var(--h) 70% 94%);
  transition: transform .3s var(--ease-mola);
}
tr:hover .al-sigla { transform: rotate(-8deg) scale(1.12); }
.al-bim { color: var(--orange-600); }
.al-final { font-size: 15px; }
.al-baixa { color: var(--s-abaixo); }
.al-vazio { color: var(--line-2); font-weight: 600; }
.al-tem-falta { color: var(--tx-forte); }
.al-total-falta { position: relative; display: inline-block; min-width: 40px; padding: 2px 8px; border-radius: 6px; z-index: 0; }
.al-total-falta::before { content: ''; position: absolute; inset: 0 auto 0 0; z-index: -1; width: var(--w); border-radius: 6px; background: var(--orange-100); transform-origin: left; animation: barra-x .9s var(--ease) .3s backwards; }
@keyframes barra-x { from { transform: scaleX(0); } }
.al-nota-freq { margin: 12px 16px 16px; }

/* faltas por bimestre */
.al-barras-bim { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.al-barras-bim li { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; font-size: 13.5px; }
.al-barras-bim .nome { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.al-barras-bim .nome i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.al-barras-bim strong { font-size: 16px; }
.al-barras-bim .trilho { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--trilho); overflow: hidden; }
.al-barras-bim .trilho span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--c); transition: width 1s var(--ease); transition-delay: calc(var(--i) * 120ms); }
.barras-prontas .al-barras-bim .trilho span { width: var(--w); }

/* fontes e critérios */
.al-fontes { font-size: 13px; color: var(--muted); }
.al-fontes summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 700; color: var(--ink-2); }
.al-fontes ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; }

/* ---------- Só cadastro (API do SIGA sem boletins) ---------- */
.al-avatar.s-cad { --c: var(--navy-500); }
.al-card.s-cad { --c: var(--navy-500); }
.al-chip.s-cad { background: var(--blue-50); color: var(--tx-forte); }
.al-grade:has(.al-card.s-cad) { grid-template-columns: repeat(auto-fill, minmax(198px, 1fr)); }
.al-card.s-cad .al-metricas dt { flex: none; }
.al-card.s-cad .al-metricas dd { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.al-aviso-api { margin-bottom: 16px; }
.al-aguardando { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 36px 20px; max-width: 560px; margin: 0 auto; }
.al-aguardando h3 { font-size: 18px; font-weight: 800; color: var(--tx-forte); }
.al-aguardando p { color: var(--ink-2); font-size: 14px; }
.al-aguardando-ic {
  position: relative; width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; margin-bottom: 6px;
  color: var(--tx-forte); background: var(--blue-50); animation: flutuar 4.5s ease-in-out infinite;
}
.al-aguardando-ic::after { content: ''; position: absolute; inset: -8px; border-radius: 28px; border: 2px solid var(--blue-100); animation: halo 3s ease-out infinite; }
.al-aguardando-giro {
  position: absolute; right: -6px; bottom: -6px; width: 26px; height: 26px; padding: 5px; border-radius: 50%;
  background: var(--orange-500); color: #fff; box-shadow: 0 4px 10px -2px rgba(232, 98, 44, .5); animation: girar 3s linear infinite;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .al-grade-ficha { grid-template-columns: minmax(0, 1fr); }
  .al-kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .al-busca { grid-column: 1 / -1; }
  .al-filtros { grid-template-columns: 1fr 1fr; }
  .al-kpis { grid-template-columns: 1fr; }
  .al-grade { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .al-cabecalho { flex-wrap: wrap; padding: 18px; }
  .al-ver-turma { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .al-avatar, .al-card, .al-linha, .al-notas tbody tr, .al-freq tbody tr, .al-kpi-ic::after, .al-foto,
  .al-total-falta::before, .al-donut-centro strong, .al-aguardando-ic, .al-aguardando-ic::after, .al-aguardando-giro { animation: none !important; }
  .al-spark path { stroke-dashoffset: 0; animation: none; }
  .al-spark circle { opacity: 1; animation: none; }
  .al-abas-indicador, .al-barras-bim .trilho span { transition: none; }
}
