/* ============================================================
 * Educo London — main.css
 * Mobile-first; base styles target 390px (iPhone 14).
 * Breakpoints: 768px (tablet), 1024px (desktop).
 * ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
table { border-collapse: collapse; width: 100%; }

/* ── Design tokens ── */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --amber-bg: #fef3c7;
  --amber-border: #fcd34d;
  --green-bg: #dcfce7;
  --green-border: #86efac;
  --red-bg: #fee2e2;
  --red-border: #fca5a5;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --tap-min: 44px;          /* Birkdale L5 — minimum tap target */
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ── Layout primitives ── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-3);
}
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 14px; color: var(--muted); margin-top: var(--space-1); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.card-title { font-size: 17px; font-weight: 600; color: var(--text); }

/* ── Buttons (44px tap target enforced) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: #eff6ff; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-muted {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-muted:hover { background: var(--bg); }
.btn-sm { min-height: 36px; padding: var(--space-2) var(--space-3); font-size: 14px; }
.btn-block { width: 100%; }

/* ── Forms ── */
.field { margin-bottom: var(--space-4); }
.field label, .form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.input, .form-control, select.form-control, textarea.form-control {
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-3);
  font-size: 16px;        /* 16px prevents iOS zoom-on-focus */
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus, .form-control:focus { border-color: var(--primary); }
textarea.form-control { min-height: 96px; resize: vertical; }
.helper {
  font-size: 13px;
  color: var(--muted);
  margin-top: var(--space-1);
}

/* ── Badges / pills ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
}
.badge-trial   { background: #fef3c7; color: #92400e; }
.badge-success { background: var(--green-bg); color: #15803d; }
.badge-warning { background: var(--amber-bg); color: #92400e; }
.badge-danger  { background: var(--red-bg); color: #991b1b; }
.badge-muted   { background: var(--bg); color: var(--muted); }

/* ── Filter pills (status filters) ── */
.pills { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  padding: var(--space-3) var(--space-5);
  background: #1e293b;
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 10000;
  max-width: calc(100% - 40px);
  box-shadow: var(--shadow-lg);
}
.toast.danger { background: var(--danger); }
.toast.success { background: var(--success); }

/* ── Nav bar (top on desktop, bottom on mobile) ── */
.nav {
  display: flex;
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2) var(--space-4);
  gap: var(--space-2);
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  margin-right: var(--space-4);
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  flex: 1;
}
.nav-link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: #eff6ff; color: var(--primary); }
.nav-user {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Nav search box ── */
.nav-search { display: flex; align-items: center; }
.nav-search-input {
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  width: 180px;
  outline: none;
}
.nav-search-input:focus { border-color: var(--primary); background: var(--surface); }
@media (max-width: 767px) {
  .nav-search-input { width: 130px; font-size: 13px; }
}

/* ── Tables (reports, lists) ── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl th, .tbl td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tbl th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 700;
  background: var(--bg);
}
.tbl tr:hover td { background: #f8fafc; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Stat tile (dashboard summary tiles) ── */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow);
}
.stat-tile-num { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-tile-label { font-size: 13px; color: var(--muted); margin-top: var(--space-1); }
.stat-tile-sub { font-size: 12px; color: var(--muted); margin-top: var(--space-1); }
.stat-tile.warn .stat-tile-num { color: var(--warning); }
.stat-tile.danger .stat-tile-num { color: var(--danger); }

/* Late attendance display in amber on the register row when read-only */
.att-late-flag { color: var(--warning); font-weight: 700; }

/* Archived row visually muted (search results, leavers tab) */
.archived-row { opacity: 0.55; font-style: italic; }
.archived-row::after { content: ' (archived)'; color: var(--muted); font-size: 12px; }

/* ── Date strip (sits above the sticky nav) ── */
.date-strip {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  /* No white-space:nowrap — allow natural wrap on narrow viewports */
}
.date-strip:empty {
  display: none; /* avoid an empty 1-line strip flashing before render */
}

/* ── Tile grid (dashboard) ── */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
.tile {
  display: block;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}
.tile:hover { box-shadow: var(--shadow-lg); text-decoration: none; }
.tile-icon { font-size: 28px; margin-bottom: var(--space-2); }
.tile-title { font-size: 17px; font-weight: 700; }
.tile-sub { font-size: 13px; color: var(--muted); margin-top: var(--space-1); }

/* ── Banners (TA alert etc.) ── */
.banner {
  border: 1px solid var(--amber-border);
  background: var(--amber-bg);
  color: #92400e;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.banner.green {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: #15803d;
}

/* ── Register page — mobile-first by design ── */
.register-list { display: flex; flex-direction: column; gap: var(--space-2); }
.register-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 64px;          /* generous tap target on mobile */
}
.register-row .student-name {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}
.register-row .student-meta {
  font-size: 12px;
  color: var(--muted);
}
.attendance-pills {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.att-pill {
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.att-pill.selected.present  { background: #16a34a; color: #fff; border-color: #16a34a; }
.att-pill.selected.late     { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.att-pill.selected.absent_notified  { background: #6366f1; color: #fff; border-color: #6366f1; }
.att-pill.selected.absent_no_notice { background: #dc2626; color: #fff; border-color: #dc2626; }
.att-pill.selected.trial    { background: #92400e; color: #fff; border-color: #92400e; }

/* ── Empty / loading states ── */
.empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  text-align: center;
  padding: var(--space-5);
  color: var(--muted);
  font-size: 14px;
}

/* ── Tablet ── */
@media (min-width: 768px) {
  .container { padding: var(--space-6); }
  .page-title { font-size: 24px; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .register-row { padding: var(--space-4); }
}

/* ── Desktop ── */
@media (min-width: 1024px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Print (register export) ── */
@media print {
  .nav, .btn, .pills { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #000; page-break-inside: avoid; }
}
