/* Kaizen — app-specific layout (Sekolah System)
 *
 * Shared components live in system.css (byte-identical across the family);
 * design tokens in tokens.css. This file holds ONLY what is Kaizen-specific:
 * the sidebar rail + mobile drawer, register screen, IDME queue, intervention
 * cards, language switch, login chrome, and app-only responsive/print rules.
 *
 * Load order: tokens.css → system.css → app.css
 * Contract: design-repo/references/sekolah-system.md
 */

/* ── App shell ─────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  display: flex;
  flex: 0 0 248px;
  width: 248px;
  min-height: 100vh;
  flex-direction: column;
  gap: 18px;
  padding: 22px 14px 16px;
  background: var(--chrome);
  color: var(--chrome-ink);
}
.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.brand { display: block; padding: 2px 10px 0; color: #fff; font-size: 22px; font-weight: 760; letter-spacing: -0.02em; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-sub { display: block; margin-top: 3px; color: #91b8aa; font-size: 11px; font-weight: 500; letter-spacing: 0.01em; }
.sidebar-close { display: none; min-width: 44px; padding: 5px; border-color: #3a5a55; background: transparent; color: #fff; font-size: 24px; }
.sidebar-close:hover { background: var(--chrome-2); color: #fff; }
.nav { display: flex; flex-direction: column; gap: 12px; }
.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-divider { height: 1px; margin: 3px 10px 0; background: #2c4a45; }
.nav-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--chrome-ink);
  font-weight: 600;
}
.nav-link:hover { background: var(--chrome-2); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16); }
.nav-link.active:hover { background: var(--accent-hover); }
.sidebar-footer { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #2c4a45; }
.who { display: block; margin-bottom: 8px; color: #a9c3ba; font-size: 13px; }
.link-button { min-height: 32px; padding: 0; border: 0; background: none; color: #a9c3ba; font-size: 13px; }
.link-button:hover { color: #fff; text-decoration: underline; }
.nav-scrim { display: none; }
.mobile-header { display: none; }

.content {
  width: min(100%, 1280px);
  min-width: 0;
  flex: 1;
  margin: 0 auto;
  padding: 34px clamp(22px, 4vw, 58px) 76px;
}
.policy-note { margin: 22px 0 0; }
.dashboard-section { margin-top: 34px; }

/* ── Register (the morning register screen) ────────────────────────────── */
/* 48px state controls: the highest-frequency, highest-consequence taps in
   the estate. Zero transition on these controls — a teacher tapping through
   40 students must never wait per tap. */
.register-table select,
.register-table input { min-height: 48px; }
.register-table select,
.register-table input,
.register-actions .button { transition: none; }
.register-form { margin-top: 18px; }
.register-summary { margin-top: 0; }
.register-summary .metric-row-primary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.register-table { min-width: 820px; border: 0; }
.register-table .student-name { font-weight: 700; }
.register-table select, .register-table input { max-width: 190px; }
.register-table .student-cell { min-width: 180px; }
.register-table .class-cell { color: var(--ink-3); }
.register-table .reason-not-applicable select { background: var(--surface-2); color: var(--ink-3); }
.status-control-group { display: flex; flex-direction: column; gap: 6px; }
.status-quick-pills { display: flex; gap: 8px; }
.quick-pill { flex: 1; min-height: 44px; padding: 4px 6px; border: 1px solid var(--border-firm); border-radius: var(--radius-sm); font-size: 13px; font-weight: 750; background: var(--surface); cursor: pointer; text-align: center; transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
.quick-pill:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.pill-present { color: var(--st-present); border-color: rgba(28, 107, 75, 0.4); }
.pill-late { color: var(--st-late); border-color: rgba(150, 97, 10, 0.4); }
.pill-absent { color: var(--st-absent); border-color: rgba(168, 53, 44, 0.4); }
.quick-pill.is-active, .quick-pill[aria-pressed="true"] { color: var(--surface); font-weight: 800; }
.pill-present.is-active, .pill-present[aria-pressed="true"] { background: var(--st-present); border-color: var(--st-present); }
.pill-late.is-active, .pill-late[aria-pressed="true"] { background: var(--st-late); border-color: var(--st-late); }
.pill-absent.is-active, .pill-absent[aria-pressed="true"] { background: var(--st-absent); border-color: var(--st-absent); }
@media (hover: hover) {
  .quick-pill:hover { opacity: 0.9; }
  .pill-present:hover { background: rgba(28, 107, 75, 0.1); }
  .pill-late:hover { background: rgba(150, 97, 10, 0.1); }
  .pill-absent:hover { background: rgba(168, 53, 44, 0.1); }
  .pill-present.is-active:hover { background: var(--st-present); }
  .pill-late.is-active:hover { background: var(--st-late); }
  .pill-absent.is-active:hover { background: var(--st-absent); }
}
.register-actions { position: sticky; bottom: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border-firm); border-radius: var(--radius); background: rgba(255, 255, 255, 0.96); box-shadow: var(--elev-float); backdrop-filter: blur(8px); }
.action-hint { color: var(--ink-3); font-size: 13px; }

/* ── Intervention / attention cards ────────────────────────────────────── */
.attention-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.attention-card { display: flex; min-width: 0; flex-direction: column; gap: 15px; padding: 17px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--elev-raised); }
.attention-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.attention-name { display: block; color: var(--ink); font-size: 16px; font-weight: 750; line-height: 1.25; }
.attention-name:hover { color: var(--accent); }
.attention-class { display: block; margin-top: 3px; color: var(--ink-3); font-size: 13px; }
.attention-details { display: grid; gap: 12px; padding-top: 2px; }
.attention-details > div { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.meta-label { flex: 0 0 100%; color: var(--ink-3); font-size: 11px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.quiet-link { align-self: flex-start; min-height: 32px; font-size: 13px; font-weight: 700; }

/* ── IDME queue ────────────────────────────────────────────────────────── */
.queue-overview { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 12px; margin-bottom: 20px; }
.queue-progress { margin: 0; }
.queue-progress-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.queue-progress-value { display: block; margin-top: 7px; color: var(--ink); font-size: 34px; line-height: 1; letter-spacing: -0.04em; }
.queue-count { display: flex; min-height: 100%; flex-direction: column; justify-content: center; margin: 0; }
.queue-table { min-width: 700px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form { display: inline-flex; }

/* ── Language switch ───────────────────────────────────────────────────── */
.lang-switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.lang-btn { min-height: 34px; padding: 5px 10px; border: 1px solid #3a5a55; border-radius: 999px; background: transparent; color: #a9c3ba; font: inherit; font-size: 12px; cursor: pointer; }
.lang-btn:hover { border-color: #fff; color: #fff; }
.lang-btn.active { border-color: #5c9c80; background: #27664f; color: #fff; font-weight: 750; }

/* ── Login chrome ──────────────────────────────────────────────────────── */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; background: var(--chrome); }
.login-card { width: min(100%, 390px); padding: 28px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 20px 55px rgba(0, 0, 0, 0.25); }
.login-card .brand { padding: 0 0 18px; color: var(--ink); }
.login-card .brand-sub { color: var(--ink-3); }
.login-card .lang-switch { margin: 0 0 18px; }
.login-card .lang-btn { border-color: var(--border-firm); color: var(--ink-3); }
.login-card .lang-btn:hover { border-color: var(--accent); color: var(--ink); }
.login-card .lang-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.google-button { margin-bottom: 2px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 2px; color: var(--ink-3); font-size: 11px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.login-divider::before, .login-divider::after { height: 1px; flex: 1; background: var(--border); content: ""; }

/* ── Public splash (control room home) ─────────────────────────────────── */
.splash-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; background: var(--paper); }
.splash-card { width: min(100%, 52rem); padding: clamp(24px, 5vw, 40px); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--elev-raised); }
.splash-card .eyebrow { margin-bottom: 8px; }
.splash-card h1 { font-size: clamp(32px, 5vw, 44px); margin-bottom: 14px; }
.splash-card p { font-size: 16px; line-height: 1.6; max-width: 44rem; color: var(--ink-2); }
.splash-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 24px; }
.splash-nav { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.splash-card .lang-btn { border-color: var(--border-firm); color: var(--ink-3); }
.splash-card .lang-btn:hover { border-color: var(--accent); color: var(--ink); }
.splash-card .lang-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }

/* ── Mobile: sidebar drawer + register/queue/intervention card collapse ── */
@media (max-width: 760px) {
  body.app-body { overflow-x: clip; }
  .layout { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(86vw, 288px); min-height: 100vh; overflow-y: auto; transform: translateX(-105%); transition: transform 180ms ease; box-shadow: 18px 0 40px rgba(0, 0, 0, 0.18); }
  html.js body.nav-open .sidebar { transform: translateX(0); }
  html:not(.js) .sidebar { position: static; width: 100%; min-height: auto; transform: none; box-shadow: none; }
  .sidebar-close { display: inline-flex; }
  .nav-scrim { position: fixed; inset: 0; z-index: 30; background: rgba(9, 29, 27, 0.52); }
  .nav-scrim[hidden] { display: none; }
  .mobile-header { display: flex; position: sticky; top: 0; z-index: 20; min-height: 68px; align-items: center; gap: 12px; margin: 0 -14px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: rgba(245, 245, 243, 0.96); backdrop-filter: blur(10px); }
  .menu-toggle { flex: 0 0 44px; width: 44px; padding: 8px; border-color: var(--border-firm); background: var(--surface); }
  .menu-icon { display: grid; gap: 4px; width: 18px; }
  .menu-icon span { display: block; height: 2px; border-radius: 2px; background: var(--ink); }
  .mobile-brand { color: var(--ink); font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
  .mobile-role { margin-left: auto; overflow: hidden; color: var(--ink-3); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
  .content { width: 100%; max-width: none; padding: 0 14px 56px; }
  .dashboard-section { margin-top: 28px; }
  .register-summary .metric-row-primary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .register-table-wrap, .queue-table-wrap, .intervention-table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .register-table, .queue-table, .intervention-table { display: block; width: 100%; min-width: 0; background: transparent; }
  .register-table thead, .queue-table thead, .intervention-table thead { display: none; }
  .register-table tbody, .queue-table tbody, .intervention-table tbody { display: grid; gap: 12px; }
  .register-table tbody tr, .queue-table tbody tr, .intervention-table tbody tr { display: grid; gap: 12px; padding: 15px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--elev-raised); }
  .register-table tbody td, .queue-table tbody td, .intervention-table tbody td { display: grid; grid-template-columns: minmax(5rem, 34%) minmax(0, 1fr); min-width: 0; align-items: center; gap: 10px; padding: 0; border: 0; }
  .register-table tbody td:first-child, .queue-table tbody td:first-child, .intervention-table tbody td:first-child { display: block; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .register-table tbody td:first-child::before, .queue-table tbody td:first-child::before, .intervention-table tbody td:first-child::before { display: none; }
  .register-table td[data-label]::before, .queue-table td[data-label]::before, .intervention-table td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: 11px; font-weight: 750; letter-spacing: 0.055em; text-transform: uppercase; }
  .register-table .student-name, .queue-table td:first-child strong, .intervention-table td:first-child > a:first-child { display: block; color: var(--ink); font-size: 16px; font-weight: 750; line-height: 1.25; }
  .register-table select, .register-table input, .queue-table .button { width: 100%; max-width: none; min-width: 0; }
  /* 16px on mobile: below this iOS Safari zooms on focus and the teacher
     loses their place mid-register. */
  .register-table select, .register-table input { font-size: 16px; }
  .intervention-table details { min-width: 0; }
  .intervention-table details input, .intervention-table details select, .intervention-table details textarea { width: 100%; max-width: none; }
  .register-table .class-cell { color: var(--ink-3); }
  .register-actions { bottom: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); align-items: stretch; flex-direction: column; gap: 9px; margin: 16px -2px 0; padding: 12px; }
  .register-actions .button { width: 100%; }
  .action-hint { font-size: 12px; line-height: 1.35; }
  .attention-grid { grid-template-columns: 1fr; }
  .queue-overview { grid-template-columns: 1fr; }
  .queue-count { min-height: 0; }
  .row-actions { align-items: stretch; }
  .row-actions .button, .row-actions .inline-form { flex: 1 1 145px; }
  .row-actions .inline-form .button { width: 100%; }
}

@media (max-width: 420px) {
  .mobile-role { display: none; }
}

/* ── Print (reports get pinned to the staff-room wall) ─────────────────── */
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .mobile-header, .nav-scrim, .no-print, .messages { display: none !important; }
  .layout, .content { display: block; width: auto; max-width: none; padding: 0; }
  .card, .table-wrap, table, .metric, .attention-card { break-inside: avoid; box-shadow: none; }
  h1 { font-size: 18px; }
  h2 { margin-top: 16px; font-size: 14px; }
  th, td { padding: 5px 7px; }
}
