/*
 * iSharetek brand palette + shared form styles.
 *
 * Colors CORRECTED in Rev. 18 to the exact values used in the client's own
 * prior build (google-sheets-manager/src/components/BrandLogo.tsx) — navy
 * #0a1c58 and orange #f36523, straight from that app's hardcoded SVG logo,
 * not the pixel-sampled approximation Rev. 15 used (#050e66/#ed712f, off
 * by a visible amount). Typeface matched too: Plus Jakarta Sans for UI/
 * headings, JetBrains Mono for tabular/numeric data — both loaded via
 * Google Fonts in each page's <head> (see e.g. allocation/base.html).
 *
 * Font sizes bumped up across the board per Rev. 15 item 2 (previous pass
 * was too small, especially the T&C/consent text under each program).
 */
:root {
  --brand-navy: #0a1c58;
  --brand-navy-dark: #071340;
  --brand-orange: #f36523;
  --bg: #f7f9fb;
  --card: #ffffff;
  --border: #dde3e8;
  --text: #1c2430;
  --muted: #5a6672;
  --ok: #1e7d3a;
  --danger: #c0392b;
  --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 17px;              /* up from the browser default 16px baseline */
  line-height: 1.5;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* White header, matching the client's own prior app (Header.tsx uses
 * bg-white, not a dark navy bar) — the logo's navy strokes are drawn for
 * a light background and disappear against a dark one, which is what
 * happened when this had a navy header. */
header.brand-header {
  background: var(--card);
  color: var(--text);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(10, 28, 88, 0.04);
}
header.brand-header .left { display: flex; align-items: center; gap: 0.9rem; }
header.brand-header img { height: 42px; }
header.brand-header h1 { font-size: 1.15rem; margin: 0; font-weight: 700; color: var(--brand-navy); }
header.brand-header .left strong { color: var(--brand-navy); font-weight: 700; }

/* Nav as a horizontal row of pill buttons — not bare text links — each
 * one clearly clickable, with a hover state and a persistent highlight
 * on whichever page is currently open. */
header.brand-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
header.brand-header nav a {
  color: var(--brand-navy);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
}
header.brand-header nav a:hover { background: #eef1fb; }
header.brand-header nav a:active { background: #dfe4f7; }
header.brand-header nav a.current { background: var(--brand-navy); color: #fff; }
header.brand-header nav a.nav-logout { color: var(--muted); margin-left: 0.3rem; padding-left: 0.9rem; border-left: 1px solid var(--border); border-radius: 0; }
/* Rev. 63 — staff logout is a POST form (Django 5+), styled to match the link above. */
header.brand-header nav form.nav-logout-form { display: inline; margin: 0; }
header.brand-header nav button.nav-logout {
  background: none; border: 0; border-left: 1px solid var(--border); cursor: pointer;
  font: inherit; font-size: 0.9rem; font-weight: 600; white-space: nowrap;
  color: var(--muted); margin-left: 0.3rem; padding: 0.5rem 0.9rem;
}
header.brand-header nav button.nav-logout:hover { background: #eef1fb; }

main.page { max-width: 780px; margin: 2rem auto; padding: 0 1rem 4rem; }

h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; color: var(--brand-navy); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem;
  margin-bottom: 1rem;
}

label { display: block; font-size: 0.95rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--muted); }

input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=password], select, textarea {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 1rem;
  background: #fff;
  color: var(--text);
}
textarea { font-family: inherit; resize: vertical; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.child-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem;
  margin-bottom: 1rem;
  position: relative;
  background: #fcfdfe;
}
.child-card h3 { margin: 0 0 0.85rem; font-size: 1.05rem; }

.remove-child { position: absolute; top: 0.8rem; right: 0.8rem; background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.9rem; }

/* Consent / T&C text — previously too small; this is the specific fix
 * requested (Rev. 15 item 2: "especially the T&C under program and
 * payment"). */
.checkbox-row { display: flex; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.9rem; font-size: 0.98rem; }
.checkbox-row input { margin-top: 0.25rem; width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.checkbox-row span { color: var(--text); line-height: 1.45; }

.voucher-number { display: none; }
.voucher-number.visible { display: block; }

button, .button-link {
  background: var(--brand-navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button-link:hover { background: var(--brand-navy-dark); }
button.secondary { background: #fff; color: var(--brand-navy); border: 1px solid var(--brand-navy); }
.accent { background: var(--brand-orange); }
.accent:hover { background: #d5601f; }
button.submit-btn { width: 100%; padding: 1rem; font-size: 1.08rem; margin-top: 1rem; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.totals { font-size: 1rem; }
.totals div { display: flex; justify-content: space-between; padding: 0.3rem 0; }
.totals .grand { font-weight: 700; font-size: 1.2rem; border-top: 1px solid var(--border); margin-top: 0.6rem; padding-top: 0.7rem; color: var(--brand-navy); }

.payment-toggle { display: flex; gap: 1.25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.payment-toggle label { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; color: var(--text); font-size: 1rem; }

#error-box, .error-box { color: var(--danger); font-size: 0.95rem; margin-top: 0.6rem; background: #fdecea; border: 1px solid #f5c6c1; border-radius: 6px; padding: 0.7rem 0.9rem; }

.campaign-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #eef2f6;
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-navy);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  margin-top: 1.5rem;
  color: var(--brand-navy);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.campaign-cta:hover { border-left-color: var(--ok); }
.campaign-cta-icon { font-size: 1.3rem; flex-shrink: 0; }

.two-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.5rem; }
@media (max-width: 600px) { .two-choice { grid-template-columns: 1fr; } }
.choice-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.choice-card:hover { border-color: var(--brand-navy); }
.choice-card .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.choice-card h3 { color: var(--brand-navy); margin: 0 0 0.5rem; font-size: 1.15rem; }
.choice-card p { color: var(--muted); font-size: 0.95rem; margin: 0; }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
th, td { padding: 0.7rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
th { background: #eef2f6; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { background: #e6f4ea; color: var(--ok); padding: 0.65rem 0.95rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.92rem; }

.badge { display: inline-block; padding: 0.18rem 0.55rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.badge.ongoing { background: #fff3cd; color: #8a6500; }
.badge.completed { background: #e6f4ea; color: var(--ok); }
.badge.pending_allocation { background: #eef2f6; color: var(--muted); }
.badge.open { background: #e6f4ea; color: var(--ok); }
.badge.commenced { background: #fff3cd; color: #8a6500; }
/* Rev. 32 — attendance status badges (Present/Absent/Cancelled). Present
   reuses .completed's green (a successful/positive outcome, not merely
   "in progress" like .ongoing's amber would imply); Absent reuses
   .pending_allocation's neutral grey; Cancelled is new — a distinct
   muted red so "the class didn't happen at all" reads as clearly
   different from "the class happened but this student wasn't there". */
.badge.cancelled { background: #fde8e8; color: #9b2c2c; }

/* Dashboard (allocation/dashboard.html) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem; margin: 1.25rem 0 2rem; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.2rem; text-decoration: none; color: var(--text); display: block; transition: border-color 0.15s; }
.stat-card:hover { border-color: var(--brand-navy); }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--brand-navy); line-height: 1; }
.stat-card .stat-value.alert { color: var(--brand-orange); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }

.dash-section { margin-bottom: 2.25rem; }
.dash-section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.75rem; }
.dash-section-header h2 { margin: 0; }
.dash-section-header a { font-size: 0.9rem; }
.empty-note { color: var(--muted); font-size: 0.92rem; padding: 1rem; background: var(--card); border: 1px dashed var(--border); border-radius: 8px; }

/* Rev. 87 — show code exactly as typed: JetBrains Mono's ligatures would draw
   >= as a single "≥" symbol, confusing for students learning the syntax. */
code, pre, kbd, samp, textarea, .mono, [style*="font-mono"] {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

/* Rev. 117 — no page wider than the screen, from phones to wide desktops: tables scroll inside
   their own box (core/tables.js wraps them), grids reflow, media fits. */
img, video, iframe { max-width: 100%; }
img { height: auto; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap > table { margin-bottom: 0; }
pre { overflow-x: auto; max-width: 100%; }
.card, .dash-section, .stat-card, .form-card { min-width: 0; }
.stat-value, .stat-label { overflow-wrap: anywhere; }
/* Rev. 141 — card figures stay on one line on every page (was the dashboard only, Rev. 134): up to $9,999.99 in
   full, then 10.5K (the 'compact' filter); money figures a little smaller */
.stat-card .stat-value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; font-size: clamp(1.35rem, 2.2vw, 1.9rem); }
.stat-card .stat-value.money { font-size: clamp(1.2rem, 1.75vw, 1.6rem); }
.stat-grid.fit { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; }
}
select { max-width: 100%; }
.card[style*="display:flex"], .card[style*="display: flex"], .stat-grid .card [style*="display:flex"], .stat-grid .card [style*="display: flex"] { flex-wrap: wrap; }
@media (max-width: 600px) {
  .card [style*="grid-template-columns"] { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important; }
}
.card { overflow-wrap: break-word; }
.card [style*="display:flex"] > *, .card [style*="display: flex"] > * { min-width: 0; }
.card[style*="display:flex"] > *, .card[style*="display: flex"] > * { min-width: 0; max-width: 100%; }
.ms-view-toggle { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* Rev. 166 — attendance status colours: Present light green, Absent light red, Cancelled grey */
.badge.st-present { background: #dcf3e2; color: #17643a; }
.badge.st-absent { background: #fde2e1; color: #a51d14; }
.badge.st-cancelled { background: #e9ecf1; color: #4a5361; }
select.att-status.st-present { background: #dcf3e2; }
select.att-status.st-absent { background: #fde2e1; }
select.att-status.st-cancelled { background: #e9ecf1; }
button:disabled, button[disabled] { background: #d6dbe3 !important; color: #6b7480 !important; border-color: #d6dbe3 !important; cursor: not-allowed; }

/* Rev. 166 — attendance change requests */
.acr { background:#fff8e6; border:1px solid #f3dca0; border-radius:10px; padding:.6rem .8rem; margin:.3rem 0 .7rem; font-size:.9rem; }
.acr-admin { background:#fff4e0; }
.acr-open { background:#eaf4ff; border-color:#bcd7f5; }
.acr-just { margin:.2rem 0 .5rem; font-style:italic; }
.acr-muted { color:var(--muted, #6b7480); font-size:.85rem; }
.acr-warn { color:#a51d14; margin:.3rem 0; font-size:.85rem; }
.acr-btns { display:flex; gap:.5rem; flex-wrap:wrap; margin-top:.4rem; }
.acr textarea, .acr-form textarea { width:100%; box-sizing:border-box; margin-top:.3rem; }
.acr-form { margin:.3rem 0 .7rem; font-size:.9rem; }
.acr-form > summary { cursor:pointer; color:var(--muted, #6b7480); }
.acr-form .acr-link { color:#1d4ed8; text-decoration:underline; }
.acr-form form { background:#f7f8fb; border:1px solid var(--border, #e3e6ec); border-radius:10px; padding:.7rem .8rem; margin-top:.4rem; display:grid; gap:.5rem; }
.acr-msg { margin:0; }

.acr-kids { border:1px solid var(--border, #e3e6ec); border-radius:8px; padding:.4rem .7rem .5rem; margin:0; display:grid; gap:.25rem; }
.acr-kids legend { font-weight:700; font-size:.85rem; padding:0 .3rem; }
.acr-kids label { display:flex; gap:.4rem; align-items:center; font-weight:400; margin:0; }
.acr-kids .acr-all { border-top:1px dashed var(--border, #e3e6ec); padding-top:.3rem; margin-top:.1rem; font-weight:600; }
tr.acr-reopened td { background:#eaf4ff; }
tr.acr-requested td { background:#fff8e6; }
.acr-hint { display:inline-block; font-size:.76rem; color:var(--muted, #6b7480); margin-top:.15rem; }
.acr-hint-open { color:#1d4ed8; }
.ck-undo small { font-weight:400; opacity:.8; }

/* Rev. 168 — every page fits, from phones to wide screens (shared by staff, portal and public pages) */
main.page.staff { max-width: 1200px; }               /* staff pages: room for the data tables (Payroll, Master Students…) */
.table-wrap.scrolls { position: relative; background: linear-gradient(to left, rgba(16,32,64,.10), rgba(16,32,64,0) 22px) right / 22px 100% no-repeat; }
.table-wrap.scrolls::before { content: "Scroll sideways for more →"; display: block; font-size: .75rem; color: var(--muted); padding: 0 0 .25rem; position: sticky; left: 0; }
@media (max-width: 900px) {
  table.stacked { border: 0; background: transparent; }
  table.stacked thead { display: none; }
  table.stacked, table.stacked tbody, table.stacked tr, table.stacked td { display: block; width: 100%; }
  table.stacked tr { background: #fff; border: 1px solid var(--border); border-radius: 10px; margin: 0 0 .6rem; padding: .35rem 0; }
  table.stacked td { border: 0; padding: .3rem .8rem; display: flex; gap: .7rem; align-items: baseline; justify-content: space-between; text-align: right; min-height: 0; }
  table.stacked td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-weight: 600; font-size: .82rem; color: var(--muted); }
  table.stacked td[data-label=""]::before { content: none; }
  table.stacked td[data-label=""] { justify-content: flex-start; text-align: left; }
  table.stacked td > form, table.stacked td > .table-wrap { flex: 1; }
  .table-wrap:has(> table.stacked) { overflow: visible; }
  /* buttons and links in a row wrap instead of running off the screen */
  .card [style*="display:flex"], .card [style*="display: flex"], main.page [style*="display:flex"], main.page [style*="display: flex"] { flex-wrap: wrap; }
  a.button-link { white-space: normal; }
}
/* staff menu: a 'Menu' button on phones */
.nav-toggle { display: none; }
@media (max-width: 760px) {
  header.brand-header.staff-header { flex-wrap: wrap; }
  header.brand-header.staff-header .nav-toggle { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; background: #fff; color: var(--brand-navy);
    border: 1px solid var(--border); border-radius: 8px; padding: .45rem .8rem; font: inherit; font-weight: 700; cursor: pointer; }
  header.brand-header.staff-header nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: .15rem; padding-top: .5rem; }
  header.brand-header.staff-header.open nav { display: flex; }
  header.brand-header.staff-header nav a { padding: .6rem .8rem; }
  header.brand-header.staff-header nav button.nav-logout { border-left: 0; margin-left: 0; text-align: left; width: 100%; }
}
/* public and Parent Portal menus on phones: every item visible — they wrap onto a second line rather than scroll
   (owner 30/11/2026: the portal's name and Log out were off-screen) */
@media (max-width: 640px) {
  header.brand-header:not(.staff-header) nav { flex-wrap: wrap; width: 100%; max-width: 100%; gap: .15rem .3rem; }
  header.brand-header:not(.staff-header) nav a { padding: .45rem .6rem; }
  header.brand-header.portal-header nav .nav-who { flex-basis: auto; margin-left: auto; font-size: .82rem; padding: .45rem .2rem .45rem .6rem; border-left: 0; }
  header.brand-header.portal-header nav a.nav-logout { margin-left: 0; padding-left: .6rem; border-left: 1px solid var(--border); border-radius: 0; }
  header.brand-header.portal-header nav .nav-break { flex-basis: 100%; height: 0; }
}

/* Rev. 168 — side-by-side panels become one column on phones and portrait tablets; long values (emails) wrap in stacked rows */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr !important; }
  table.stacked td { overflow-wrap: anywhere; word-break: break-word; }
  table.stacked td > * { max-width: 100%; }
}
/* Rev. 168 — staff data tables a little denser on wide screens, so more columns fit without scrolling */
@media (min-width: 901px) { main.page.staff th, main.page.staff td { padding: .55rem .65rem; font-size: .9rem; } }
.avail-hint:empty { display: none; }
@media (max-width: 900px) { table.stacked td { flex-wrap: wrap; } }
main.page.staff td a.button-link, main.page.staff td button { padding: .35rem .6rem; font-size: .82rem; }  /* Rev. 168 — row buttons compact */
[hidden] { display: none !important; }  /* Rev. 168 — hidden stays hidden (a stacked row's display:block overrode it) */
