/*
 * SIGEduc v0.26 - Camada de experiência do usuário sobre o GovBR Design System 3.7.
 * Usa os tokens do GovBR (cores, espaçamentos, fonte Rawline) e componentes br-*.
 * Contraste mínimo WCAG 2.1 AA em todos os pares texto/fundo.
 */
:root {
  --ux-success: #168821;      /* GovBR success */
  --ux-success-bg: #e3f5e1;
  --ux-warning: #8a6100;      /* texto escuro sobre amarelo para manter contraste AA */
  --ux-warning-bar: #ffcd07;  /* GovBR warning */
  --ux-warning-bg: #fff5c2;
  --ux-danger: #e52207;       /* GovBR danger */
  --ux-danger-bg: #fde0db;
  --ux-info: #155bcb;         /* GovBR info / primary */
  --ux-info-bg: #d4e5ff;
  --ux-neutral: #555;
  --ux-neutral-bg: #ededed;
  --ux-border: #ccc;
  --ux-radius: 8px;
  --ux-shadow: 0 1px 6px rgba(51, 51, 51, 0.16);
}

/* ---------- Ambiente de demonstração ---------- */
.demo-ribbon { background: var(--ux-warning-bar); color: #1b1b1b; font-size: 0.875rem; font-weight: 600; text-align: center; padding: 6px 16px; }
.demo-ribbon a { color: #1b1b1b; text-decoration: underline; }

/* ---------- Etiquetas de situação (Status::tag) ---------- */
.br-tag.status-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 100em; padding: 2px 10px; font-size: 0.8125rem; font-weight: 600; line-height: 1.6; white-space: nowrap; min-height: auto; height: auto; }
.br-tag.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status-chip--success { background: var(--ux-success-bg) !important; color: var(--ux-success) !important; }
.status-chip--warning { background: var(--ux-warning-bg) !important; color: var(--ux-warning) !important; }
.status-chip--danger { background: var(--ux-danger-bg) !important; color: #b51d09 !important; }
.status-chip--info { background: var(--ux-info-bg) !important; color: #0c326f !important; }
.status-chip--neutral { background: var(--ux-neutral-bg) !important; color: var(--ux-neutral) !important; }

/* ---------- Painel ---------- */
.dash-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dash-eyebrow { color: var(--ux-info); font-weight: 600; margin: 0 0 4px; }
.dash-title { margin: 0; font-size: 2rem; font-weight: 500; }
.dash-scope { color: var(--ux-neutral); margin: 6px 0 0; }
.dash-scope-label { font-weight: 600; }
.dash-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-actions .sigeduc-icon, .service-head .sigeduc-icon, .dash-panel-title .sigeduc-icon { width: 1.1em; height: 1.1em; vertical-align: -0.15em; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 20px; background: #fff; border-radius: var(--ux-radius); box-shadow: var(--ux-shadow); border-left: 4px solid var(--ux-info); color: inherit; text-decoration: none; }
a.kpi-card:hover { background: #f8faff; text-decoration: none; }
a.kpi-card:focus-visible, a.service-card:focus-visible { outline: 4px dashed #c2850c; outline-offset: 2px; }
.kpi-card--success { border-left-color: var(--ux-success); }
.kpi-card--warning { border-left-color: var(--ux-warning-bar); }
.kpi-card--danger { border-left-color: var(--ux-danger); }
.kpi-icon { position: absolute; right: 16px; top: 14px; color: var(--ux-info); opacity: 0.35; }
.kpi-icon .sigeduc-icon { width: 22px; height: 22px; }
.kpi-label { font-size: 0.875rem; color: var(--ux-neutral); padding-right: 28px; min-height: 2.6em; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.1; color: #1b1b1b; font-variant-numeric: tabular-nums; }

.dash-alert { margin-bottom: 24px; }
.dash-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; margin-bottom: 24px; }
.dash-panel { background: #fff; border-radius: var(--ux-radius); box-shadow: var(--ux-shadow); padding: 20px 24px; margin-bottom: 24px; }
.dash-columns .dash-panel { margin-bottom: 0; }
.dash-panel-title { font-size: 1.125rem; font-weight: 600; margin: 0 0 8px; color: #1b1b1b; }
.dash-section-title { font-size: 1.25rem; font-weight: 600; margin: 8px 0 16px; }
.dash-muted { color: var(--ux-neutral); font-size: 0.875rem; margin: 0 0 12px; }
.dash-empty { color: var(--ux-neutral); background: #f8f8f8; border-radius: var(--ux-radius); padding: 16px; margin: 8px 0 0; }

.risk-list { list-style: none; margin: 8px 0 0; padding: 0; }
.risk-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #ededed; }
.risk-list li:last-child { border-bottom: 0; }
.risk-list strong { display: block; font-weight: 600; }
.risk-list small { color: var(--ux-neutral); }
.risk-rate { font-weight: 700; color: #b51d09; background: var(--ux-danger-bg); border-radius: 100em; padding: 2px 10px; font-variant-numeric: tabular-nums; }

.bar-list { list-style: none; margin: 8px 0 0; padding: 0; }
.bar-list li { display: grid; grid-template-columns: minmax(140px, 46%) 1fr 64px; align-items: center; gap: 12px; padding: 7px 0; }
.bar-name { font-size: 0.9375rem; line-height: 1.25; }
.bar-track { position: relative; height: 14px; background: #ededed; border-radius: 100em; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ux-info); border-radius: 100em; }
.bar-fill--warning { background: var(--ux-warning-bar); }
.bar-goal { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #333; }
.bar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.service-card { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px; background: #fff; border-radius: var(--ux-radius); box-shadow: var(--ux-shadow); color: inherit; text-decoration: none; border-top: 4px solid var(--ux-info); }
.service-card:hover { background: #f8faff; text-decoration: none; }
.service-head { font-weight: 600; color: var(--ux-info); margin-bottom: 6px; }
.service-value { font-size: 1.75rem; font-weight: 700; color: #1b1b1b; font-variant-numeric: tabular-nums; }
.service-card small { color: var(--ux-neutral); margin-top: 6px; }

.lesson-timeline { list-style: none; margin: 4px 0 0; padding: 0; }
.lesson-timeline li { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #ededed; }
.lesson-timeline li:last-child { border-bottom: 0; }
.lesson-time { font-weight: 700; color: var(--ux-info); font-variant-numeric: tabular-nums; }
.lesson-body strong { display: block; }
.lesson-body span { color: var(--ux-neutral); font-size: 0.875rem; }

.text-right { text-align: right; }

/* ---------- Chamada rápida ---------- */
.att-toolbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin: 0 0 16px; background: #fff; border-radius: var(--ux-radius); box-shadow: var(--ux-shadow); }
.att-counters { display: flex; flex-wrap: wrap; gap: 8px; font-weight: 600; }
.att-counter { border-radius: 100em; padding: 4px 12px; font-variant-numeric: tabular-nums; }
.att-counter--present { background: var(--ux-success-bg); color: var(--ux-success); }
.att-counter--absent { background: var(--ux-danger-bg); color: #b51d09; }
.att-counter--justified { background: var(--ux-warning-bg); color: var(--ux-warning); }
.att-seg { display: inline-flex; border: 1px solid var(--ux-border); border-radius: 100em; overflow: hidden; }
.att-seg input { position: absolute; opacity: 0; pointer-events: none; }
.att-seg label { margin: 0; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 0.875rem; color: #333; border-left: 1px solid var(--ux-border); min-width: 44px; text-align: center; user-select: none; }
.att-seg label:first-of-type { border-left: 0; }
.att-seg input:focus-visible + label { outline: 4px dashed #c2850c; outline-offset: -4px; }
.att-seg input[value="PRESENT"]:checked + label { background: var(--ux-success); color: #fff; }
.att-seg input[value="ABSENT"]:checked + label { background: var(--ux-danger); color: #fff; }
.att-seg input[value="JUSTIFIED"]:checked + label { background: var(--ux-warning-bar); color: #1b1b1b; }
.att-seg input[value="EXCUSED"]:checked + label { background: #555; color: #fff; }
.att-row--absent { background: #fff7f5; }
.att-just[hidden] { display: none !important; }

@media (max-width: 768px) {
  .dash-title { font-size: 1.5rem; }
  .kpi-value { font-size: 1.6rem; }
  .bar-list li { grid-template-columns: 1fr 56px; }
  .bar-list .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .lesson-timeline li { grid-template-columns: 48px 1fr; }
  .lesson-timeline .br-button { grid-column: 2; justify-self: start; }
  /* Tabela de chamada vira lista de cartões no celular */
  .att-table thead { display: none; }
  .att-table tr { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid #ededed; }
  .att-table td, .att-table th[scope="row"] { border: 0 !important; padding: 0 !important; }
  .att-table td:first-child { display: none; }
  .att-seg label { padding: 10px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Texto apenas para leitores de tela */
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.att-table th[scope="row"] { background: transparent !important; text-align: left; }
.att-table td, .att-table th { vertical-align: middle; }
.lesson-summary summary { cursor: pointer; }

/* v0.29 — relatórios da secretaria (tela) */
.report-table th, .report-table td { text-align: center; vertical-align: top; }
.report-table th.l, .report-table td.l { text-align: left; }
.report-table tfoot th, .report-table tfoot td { background: #f3f5f8; font-weight: 700; }
.report-table td small, .report-table th small { color: #555; font-weight: 400; }
.report-over td { background: #fdecea; }
.report-h2 { font-size: 1.1rem; margin: 0; padding: 12px 16px 8px; }
.report-h2 small { font-weight: 400; color: #555; font-size: .85rem; }
.report-note { padding: 4px 16px 12px; margin: 0; font-size: .85rem; color: #555; }
.report-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.report-block { overflow-x: auto; }
.report-table td.report-sign { min-width: 240px; }
