/* ─────────────────────────────────────────────────────────────────────────
 * Sekolah System — shared component layer
 *
 * BYTE-IDENTICAL across Kaizen and KehadiranKokum. If a rule must differ per
 * app, it does NOT belong here — it goes in that app's app.css, or the
 * behaviour is promoted to a token in tokens.css.
 *
 * References ONLY shared token names (tokens.css §1–§5): --surface,
 * --surface-2, --paper, --border, --border-firm, --ink, --ink-2, --ink-3,
 * --accent, --accent-hover, --accent-soft, --chrome, --st-*, --radius-*,
 * --elev-*, --text-*, --space-*, --font-*, --motion-*, --focus-ring.
 * Never a legacy alias, never an app-specific class name.
 *
 * Contract: design-repo/references/sekolah-system.md
 * ─────────────────────────────────────────────────────────────────────── */

/* ── Reset ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

/* ── Skip link (a11y floor) ────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  background: var(--chrome);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ── Base typography ───────────────────────────────────────────────────── */
html { min-width: 320px; background: var(--paper); }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
}
body.nav-open { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
button, input, select, textarea { font: inherit; }
h1 { margin: 0 0 5px; color: var(--ink); font-size: clamp(28px, 3vw, 36px); line-height: 1.12; letter-spacing: -0.035em; }
h2 { margin: 0; color: var(--ink); font-size: 21px; line-height: 1.2; letter-spacing: -0.02em; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: 0.075em; text-transform: uppercase; }
.subtitle { margin: 0; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.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; }

/* ── Page furniture ────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin: 0 0 28px; }
.page-header-action { flex: 0 0 auto; white-space: nowrap; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-note { margin: 5px 0 0; color: var(--ink-3); font-size: 13px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid var(--border-firm);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}
button:hover, .button:hover { border-color: var(--accent); color: var(--accent-hover); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--accent), transparent 72%);
  outline-offset: 2px;
}
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.68; }
.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.button-danger { color: var(--st-absent); }
.button-block { width: 100%; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.messages { margin-bottom: 18px; }
.message { margin-bottom: 8px; padding: 12px 15px; border: 1px solid #bfd8c8; border-radius: var(--radius-sm); background: var(--accent-soft); }
.message.error { border-color: #f0c4c0; background: var(--st-absent-soft); }
.message.success { border-color: #bfd8c8; background: var(--accent-soft); }
.message.info { border-color: #c3d4e6; background: #eef4fb; }
.message.warning { border-color: #ecd9a0; background: var(--st-late-soft); }

/* ── Cards + callouts ──────────────────────────────────────────────────── */
.card, .callout {
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--elev-raised);
}
.empty-state { min-height: 120px; }
.callout { background: #eef5fb; border-color: #c8d9e6; box-shadow: none; }
.callout-leadership { padding: 20px 22px; background: #edf7f1; border-color: #bdd9ca; border-top: 3px solid var(--accent); }
.callout-status { background: #f1f5f3; border-color: var(--border-firm); }
.callout-success { background: var(--accent-soft); border-color: #bdd9ca; }
.callout-kicker { color: var(--accent-hover); font-size: 12px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; }
.callout-message { margin: 8px 0 0; color: var(--ink); font-size: 17px; font-weight: 650; line-height: 1.38; }
.callout .author { margin-top: 9px; color: var(--ink-3); font-size: 13px; }

/* ── Metrics ───────────────────────────────────────────────────────────── */
.metric-row { display: grid; gap: 12px; margin-bottom: 12px; }
.metric-row-primary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-row-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric {
  min-width: 0;
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--elev-raised);
}
.metric .value { color: var(--ink); font-size: 31px; font-weight: 780; line-height: 1; letter-spacing: -0.04em; }
.metric .label { margin-top: 7px; color: var(--ink-3); font-size: 13px; font-weight: 600; }
.metric.present { border-top: 3px solid var(--st-present); }
.metric.present .value { color: var(--st-present); }
.metric.late { border-top: 3px solid var(--st-late); }
.metric.late .value { color: var(--st-late); }
.metric.absent { border-top: 3px solid var(--st-absent); }
.metric.absent .value { color: var(--st-absent); }
.metric-secondary { background: var(--surface-2); box-shadow: none; }
.progress-track { width: 100%; height: 8px; margin-top: 13px; overflow: hidden; border-radius: 999px; background: #dce8e0; }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--elev-raised); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.data-table { min-width: 620px; border: 0; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); color: var(--ink-3); font-size: 12px; font-weight: 750; letter-spacing: 0.065em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdfb; }
.compact-table { min-width: 500px; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.1; }
.badge-present, .badge-resolved { background: var(--st-present-soft); color: var(--st-present); }
.badge-late, .badge-guardian_contact { background: var(--st-late-soft); color: var(--st-late); }
.badge-absent { background: var(--st-absent-soft); color: var(--st-absent); }
.badge-neutral, .badge-monitor, .badge-mentor, .badge-counsellor, .badge-pk_hem { background: var(--st-none-soft); color: var(--st-none); }
/* Family parity: Kokum has these states. Kaizen's model has no excused/none
   today — no template wires them yet; do not invent product states. */
.badge-excused { background: var(--st-excused-soft); color: var(--st-excused); }
.badge-none { background: var(--st-none-soft); color: var(--st-none); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
form label { display: block; margin: 0; color: var(--ink); font-size: 13px; font-weight: 700; }
form input[type="text"], form input[type="password"], form input[type="date"], form input[type="email"], form select, form textarea {
  width: 100%;
  max-width: 420px;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border-firm);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}
form textarea { min-height: 96px; resize: vertical; }
form .helptext, .help { display: block; margin-top: 4px; color: var(--ink-3); font-size: 12.5px; }
.form-errors { margin-bottom: 12px; padding: 12px 14px; border: 1px solid #f0c4c0; border-radius: var(--radius-sm); background: var(--st-absent-soft); color: var(--st-absent); }
.form-errors ul { margin: 0; padding-left: 18px; }
.form-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 12px; }
.form-row label { margin: 0; }
.form-row input, .form-row select { max-width: 220px; }
.form-card { width: min(100%, 650px); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 16px; }

/* ── Toolbar + filter bar ──────────────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.toolbar form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.toolbar form label { display: grid; gap: 5px; }
.toolbar form input, .toolbar form select { max-width: 210px; }
.filter-bar { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.filter-bar form { width: 100%; }
.filter-bar form .button { align-self: end; }

/* ── Empty + disclosure ────────────────────────────────────────────────── */
.empty { padding: 38px 14px; color: var(--ink-3); text-align: center; }
details.action-form { margin-top: 3px; }
details.action-form summary { min-height: 32px; padding: 6px 0; color: var(--accent); cursor: pointer; font-size: 13.5px; font-weight: 700; }
details.action-form form { margin-top: 8px; padding: 12px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
details.action-form textarea, details.action-form input, details.action-form select { max-width: 340px; }

/* ── Global floors ─────────────────────────────────────────────────────── */
html { text-size-adjust: 100%; }
html, body { touch-action: manipulation; }
h1, h2, .attention-name, .brand { text-wrap: balance; }
p { text-wrap: pretty; }
.metric .value, .queue-progress-value, td.num, th.num { font-variant-numeric: tabular-nums; }

/* ── Shared responsive (app-agnostic rules only) ───────────────────────── */
@media (max-width: 760px) {
  .page-header { flex-direction: column; gap: 15px; margin: 26px 0 22px; }
  .page-header-action { width: 100%; }
  .section-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .section-heading > .button { width: 100%; }
  .messages { margin-top: 16px; }
  .metric-row-primary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .metric-row-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { padding: 14px 12px; border-radius: 12px; }
  .metric .value { font-size: 26px; }
  .metric .label { font-size: 12px; line-height: 1.25; }
  .table-wrap { border-radius: 12px; }
  .data-table { min-width: 620px; }
  .filter-bar { padding: 13px; }
  .filter-bar form { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .filter-bar form label, .filter-bar form input, .filter-bar form select, .filter-bar form .button { width: 100%; max-width: none; }
}

@media (max-width: 420px) {
  .metric .value { font-size: 24px; }
}
