/* ════════════════════════════════════════════════════════════════════
   theme.css — Design System "Academia Hebraico"
   Fundação visual compartilhada pelas páginas de gestão (Painel da
   Instituição, Módulo do Professor) e novos módulos do aluno.
   Tokens herdados de mapa-biblico.html, refinados.  SEM ROSA.
   ════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Superfícies ── */
  --bg:        #fdf6e3;   /* areia clara */
  --bg2:       #f5e6c8;   /* areia secundária */
  --surface:   #ffffff;
  --surface-2: #fbf4e4;   /* card sutil sobre areia */

  /* ── Marca ── */
  --gold:   #c8860a;  --gold-l: #f0d060;  --gold-d: #8a5e00;
  --pur:    #6d28d9;  --pur-l:  #8b5cf6;  --pur-d:  #4c1d95;
  --teal:   #0d9488;  --teal-l: #2dd4bf;  --teal-d: #0f766e;

  /* ── Semânticas ── */
  --green:  #059669;  --green-l:#d1fae5;
  --red:    #dc2626;  --red-l:  #fee2e2;
  --orange: #ea580c;  --orange-l:#ffedd5;
  --blue:   #1d4ed8;  --blue-l: #dbeafe;

  /* ── Texto ── */
  --text:    #1a0a1e;
  --muted:   #6b5e7a;
  --faint:   #9b8fa8;
  --on-dark: #fdf6e3;

  /* ── Linhas / sombras ── */
  --border:   rgba(26,10,30,.10);
  --border-2: rgba(26,10,30,.16);
  --shadow:    0 4px 20px rgba(26,10,30,.08);
  --shadow-lg: 0 18px 60px rgba(26,10,30,.22);
  --ring:      0 0 0 3px rgba(109,40,217,.18);

  /* ── Raios ── */
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px; --r-full: 999px;

  /* ── Espaçamento (escala 4px) ── */
  --s1:.25rem; --s2:.5rem; --s3:.75rem; --s4:1rem; --s5:1.5rem; --s6:2rem; --s7:3rem;

  /* ── Tipografia ── */
  --f-display: 'Cinzel', Georgia, serif;        /* títulos */
  --f-body:    'Nunito', system-ui, sans-serif; /* corpo */
  --f-quote:   'Crimson Text', Georgia, serif;  /* citações */
  --f-heb:     'Frank Ruhl Libre', 'Times New Roman', serif;
  --heb-size:  1.55rem;
}

/* ── Reset enxuto ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: .01em; }
a { color: var(--pur-d); text-decoration: none; }
a:hover { text-decoration: underline; }
.heb { font-family: var(--f-heb); font-size: var(--heb-size); direction: rtl; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ════════════════════════════════════════════════════════════════════
   Layout do app de gestão
   ════════════════════════════════════════════════════════════════════ */
.app-shell { max-width: 1180px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); }
.page-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head .title { font-family: var(--f-display); font-size: 1.5rem; color: var(--text); }
.page-head .sub { color: var(--muted); font-size: .92rem; }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ════════════════════════════════════════════════════════════════════
   Botões
   ════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font-family: var(--f-body); font-weight: 800; font-size: .9rem;
  padding: .62rem 1.1rem; border-radius: var(--r-md);
  border: 1.5px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .18s, box-shadow .18s, background .18s, border-color .18s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--pur); color: #fff; box-shadow: 0 6px 18px rgba(109,40,217,.28); }
.btn-primary:hover { background: var(--pur-d); }
.btn-gold { background: var(--gold); color: #fff; box-shadow: 0 6px 18px rgba(200,134,10,.28); }
.btn-gold:hover { background: var(--gold-d); }
.btn-ghost { background: rgba(109,40,217,.08); color: var(--pur-d); border-color: rgba(109,40,217,.22); }
.btn-ghost:hover { background: rgba(109,40,217,.14); }
.btn-soft { background: var(--surface); color: var(--text); border-color: var(--border-2); box-shadow: var(--shadow); }
.btn-soft:hover { border-color: var(--gold); }
.btn-sm { padding: .4rem .7rem; font-size: .8rem; border-radius: var(--r-sm); }
.btn-icon { padding: .5rem; width: 2.2rem; height: 2.2rem; }

/* ════════════════════════════════════════════════════════════════════
   Cards e KPIs
   ════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s5);
}
.card-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s4); }
.card-head .ttl { font-family: var(--f-display); font-size: 1.02rem; }
.card-head .act { margin-left: auto; }

.kpi { position: relative; overflow: hidden; }
.kpi .label { font-size: .8rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-family: var(--f-display); font-size: 2.1rem; color: var(--text); line-height: 1; margin: .35rem 0 .2rem; }
.kpi .delta { font-size: .82rem; font-weight: 800; display: inline-flex; align-items: center; gap: .25em; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }
.kpi .accent { position: absolute; inset: 0 auto 0 0; width: 4px; border-radius: var(--r-lg) 0 0 var(--r-lg); background: var(--gold); }
.kpi.kpi-pur .accent { background: var(--pur); }
.kpi.kpi-teal .accent { background: var(--teal); }
.kpi.kpi-green .accent { background: var(--green); }

/* ════════════════════════════════════════════════════════════════════
   Pills / badges
   ════════════════════════════════════════════════════════════════════ */
.pill {
  display: inline-flex; align-items: center; gap: .35em;
  padding: .2rem .6rem; border-radius: var(--r-full);
  font-size: .74rem; font-weight: 800; line-height: 1.4;
}
.pill-gold  { background: rgba(200,134,10,.14); color: var(--gold-d); }
.pill-pur   { background: rgba(109,40,217,.12); color: var(--pur-d); }
.pill-teal  { background: rgba(13,148,136,.14); color: var(--teal-d); }
.pill-green { background: var(--green-l); color: var(--green); }
.pill-red   { background: var(--red-l); color: var(--red); }
.pill-orange{ background: var(--orange-l); color: var(--orange); }
.pill-muted { background: rgba(26,10,30,.06); color: var(--muted); }

/* severidade de alertas */
.sev-info  { background: var(--blue-l);  color: var(--blue); }
.sev-warn  { background: var(--orange-l);color: var(--orange); }
.sev-high  { background: var(--red-l);   color: var(--red); }
.sev-good  { background: var(--green-l); color: var(--green); }

/* ════════════════════════════════════════════════════════════════════
   Abas / navegação segmentada
   ════════════════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: .2rem; background: rgba(26,10,30,.05); padding: .25rem; border-radius: var(--r-md); flex-wrap: wrap; }
.tab {
  flex: 1; min-width: max-content; text-align: center; cursor: pointer;
  padding: .5rem .9rem; border: none; background: transparent;
  font-family: var(--f-body); font-weight: 800; font-size: .85rem; color: var(--muted);
  border-radius: var(--r-sm); transition: background .18s, color .18s;
}
.tab.on { background: var(--surface); color: var(--pur-d); box-shadow: var(--shadow); }

/* ════════════════════════════════════════════════════════════════════
   Barra de filtros (período + busca com 4 modos)
   ════════════════════════════════════════════════════════════════════ */
.filterbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s4); }
.field { display: flex; flex-direction: column; gap: .2rem; }
.field label { font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.input, .select {
  font-family: var(--f-body); font-size: .88rem; color: var(--text);
  padding: .5rem .7rem; border: 1.5px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--surface); transition: border-color .18s, box-shadow .18s;
}
.input:focus, .select:focus { outline: none; border-color: var(--pur); box-shadow: var(--ring); }
.search-wrap { display: flex; align-items: stretch; gap: 0; }
.search-wrap .input { border-radius: var(--r-sm) 0 0 var(--r-sm); border-right: none; min-width: 180px; }
.search-wrap .select { border-radius: 0 var(--r-sm) var(--r-sm) 0; font-weight: 700; color: var(--muted); }

/* ════════════════════════════════════════════════════════════════════
   Tabelas
   ════════════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl thead th {
  text-align: left; font-family: var(--f-body); font-weight: 800; font-size: .76rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--gold-d);
  background: rgba(200,134,10,.08); padding: .7rem .9rem; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.tbl tbody td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable { cursor: pointer; transition: background .15s; }
.tbl tbody tr.clickable:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable::after { content: ' ⇅'; opacity: .4; font-size: .8em; }
.tbl th.sort-asc::after { content: ' ↑'; opacity: 1; }
.tbl th.sort-desc::after { content: ' ↓'; opacity: 1; }

/* ════════════════════════════════════════════════════════════════════
   Drill-down (afunilamento estilo ScriptCase)
   ════════════════════════════════════════════════════════════════════ */
.drill-row > td { background: var(--surface-2); }
.drill-panel { padding: var(--s4) var(--s4) var(--s5); border-left: 3px solid var(--gold); margin: .2rem 0 .4rem; }
.drill-trail { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); margin-bottom: var(--s3); flex-wrap: wrap; }
.drill-trail .crumb { font-weight: 800; }
.drill-trail .crumb.link { color: var(--pur-d); cursor: pointer; }
.drill-trail .sep { opacity: .5; }
.expander { transition: transform .2s; display: inline-block; }
.expander.open { transform: rotate(90deg); }

/* ════════════════════════════════════════════════════════════════════
   Modal / bottom-sheet
   ════════════════════════════════════════════════════════════════════ */
.overlay { position: fixed; inset: 0; background: rgba(10,5,20,.55); backdrop-filter: blur(4px); z-index: 600; display: none; align-items: center; justify-content: center; }
.overlay.open { display: flex; }
.sheet {
  background: var(--surface); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); animation: sheetIn .26s cubic-bezier(.34,1.56,.64,1);
}
.sheet-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s5) var(--s3); border-bottom: 1px solid var(--border); }
.sheet-body { padding: var(--s5); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) {
  .overlay { align-items: flex-end; }
  .sheet { border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
}

/* ════════════════════════════════════════════════════════════════════
   Alertas pastorais
   ════════════════════════════════════════════════════════════════════ */
.alert-card { display: flex; gap: var(--s3); padding: var(--s4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); align-items: flex-start; }
.alert-card.unread { box-shadow: inset 3px 0 0 var(--gold); }
.alert-card .ic { font-size: 1.4rem; line-height: 1; }
.alert-card .body { flex: 1; min-width: 0; }
.alert-card .ttl { font-weight: 800; font-size: .92rem; }
.alert-card .msg { color: var(--muted); font-size: .86rem; margin-top: .15rem; }
.alert-card .meta { display: flex; align-items: center; gap: .5rem; margin-top: .4rem; }

/* ════════════════════════════════════════════════════════════════════
   Estados vazios
   ════════════════════════════════════════════════════════════════════ */
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--muted); }
.empty .ic { font-size: 2.6rem; opacity: .6; }
.empty .ttl { font-family: var(--f-display); font-size: 1.05rem; color: var(--text); margin: .5rem 0 .25rem; }

/* ════════════════════════════════════════════════════════════════════
   Gráficos (auxiliares para charts.js — SVG)
   ════════════════════════════════════════════════════════════════════ */
.chart { width: 100%; display: block; overflow: visible; font-family: var(--f-body); }
.chart .axis { stroke: var(--border-2); stroke-width: 1; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .lbl { fill: var(--muted); font-size: 11px; }
.chart .bar { transition: opacity .15s; cursor: pointer; }
.chart .bar:hover { opacity: .82; }
.chart-legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: var(--s2); }
.chart-legend .item { display: inline-flex; align-items: center; gap: .35em; }
.chart-legend .dot { width: .7em; height: .7em; border-radius: 2px; }
.heatcell { rx: 2; }

/* paleta de séries (sem rosa) */
.series-1 { color: var(--gold); }  .fill-1 { fill: var(--gold); }
.series-2 { color: var(--pur); }   .fill-2 { fill: var(--pur); }
.series-3 { color: var(--teal); }  .fill-3 { fill: var(--teal); }
.series-4 { color: var(--green); } .fill-4 { fill: var(--green); }
.series-5 { color: var(--orange); }.fill-5 { fill: var(--orange); }
.series-6 { color: var(--blue); }  .fill-6 { fill: var(--blue); }

/* ════════════════════════════════════════════════════════════════════
   Toast
   ════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(14px);
  background: var(--text); color: var(--on-dark); padding: .7rem 1.1rem; border-radius: var(--r-full);
  font-weight: 700; font-size: .88rem; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 900;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ════════════════════════════════════════════════════════════════════
   Modo Estudo Sério (Frente 9) — visual sóbrio, sem festa
   ════════════════════════════════════════════════════════════════════ */
body.serious { --gold-l: var(--gold); }
body.serious .kpi .accent,
body.serious .confetti,
body.serious .badge-celebrate { display: none !important; }
body.serious .btn:hover { transform: none; }
body.serious * { animation-duration: 0s !important; }

/* ── Acessibilidade ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
