/* ============================================================
   نتيجة الثانوية العامة 2026
   Mobile-first, RTL. No webfonts on purpose: an external font
   request is a render-blocking round trip, and on result day the
   traffic is overwhelmingly Egyptian mobile networks.
   ============================================================ */

:root {
  --bg:        #f4f6f8;
  --card:      #ffffff;
  --ink:       #14202b;
  --ink-soft:  #5b6b7a;
  --line:      #e2e8ee;

  --brand:     #0f766e;
  --brand-ink: #0b5c56;
  --brand-bg:  #e6f5f3;

  --ok:        #15803d;
  --ok-bg:     #e8f7ee;
  --warn:      #b45309;
  --warn-bg:   #fdf3e3;
  --danger:    #b91c1c;
  --danger-bg: #fdecec;
  --muted:     #475569;
  --muted-bg:  #eef1f4;

  --radius:    14px;
  --shadow:    0 1px 2px rgba(16,32,48,.06), 0 8px 24px rgba(16,32,48,.06);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Naskh Arabic", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ---------- Header ---------- */
.site-head { text-align: center; padding: 20px 0 26px; }

.site-head .logo {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 10px;
}

.site-head h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.2px;
  color: var(--brand-ink);
}

.site-head .sub {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ---------- Cards ---------- */
.search-card,
.gate-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.search-card > label {
  display: block;
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 15.5px;
}

.search-row { display: flex; gap: 8px; }

input[type="search"],
input[type="tel"],
input[type="password"],
select {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px; /* < 16px makes iOS Safari zoom on focus */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input[type="search"] { -webkit-appearance: none; appearance: none; }

input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,118,110,.15);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%235b6b7a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  background-size: 12px;
  padding-left: 38px;
}

button {
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 10px;
  padding: 13px 22px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .05s;
}

button:hover  { background: var(--brand-ink); }
button:active { transform: translateY(1px); }

button.primary { width: 100%; padding: 15px; font-size: 16.5px; margin-top: 4px; }

.hint {
  margin: 12px 0 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* ---------- Gate ---------- */
.gate-card { text-align: center; }

.gate-lock { font-size: 34px; line-height: 1; }

.gate-card h2 {
  margin: 10px 0 6px;
  font-size: 20px;
  font-weight: 800;
}

.gate-lead {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 15px;
}

.gate-form { text-align: right; }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 6px;
}

.field.has-error input,
.field.has-error select { border-color: var(--danger); }

.field .err {
  display: block;
  margin-top: 6px;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
}

.gate-note {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.gate-note strong { color: var(--ink); }
.gate-note a { color: var(--brand); }

/* ---------- Notices ---------- */
.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
}

.notice.ok    { background: var(--ok-bg);     color: var(--ok);     }
.notice.error { background: var(--danger-bg); color: var(--danger); }

/* ---------- Results ---------- */
.results { margin-top: 22px; }

.results-count {
  margin: 0 0 12px;
  font-size: 14.5px;
  color: var(--ink-soft);
  font-weight: 600;
}

.results-count .more { color: var(--warn); font-weight: 700; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 12px;
  /* status colour lives on the inline-start edge */
  border-inline-start: 5px solid var(--muted);
}

.card.kind-ok           { border-inline-start-color: var(--ok);     }
.card.kind-second_round { border-inline-start-color: var(--warn);   }
.card.kind-failed       { border-inline-start-color: var(--danger); }
.card.kind-absent       { border-inline-start-color: var(--muted);  }

.card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card .name {
  margin: 0;
  font-size: 17.5px;
  font-weight: 800;
  line-height: 1.5;
}

.badge {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--muted-bg);
  color: var(--muted);
  white-space: nowrap;
}

.kind-ok           .badge { background: var(--ok-bg);     color: var(--ok);     }
.kind-second_round .badge { background: var(--warn-bg);   color: var(--warn);   }
.kind-failed       .badge { background: var(--danger-bg); color: var(--danger); }

.card dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.card dl > div { text-align: center; }

.card dt {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 3px;
}

.card dd {
  margin: 0;
  font-weight: 800;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.card dd small {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.card .seat   { letter-spacing: .5px; }
.card .degree { color: var(--brand-ink); }
.card .pct    { color: var(--ink-soft); font-size: 17px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.empty-icon { font-size: 38px; }

.empty h2 { margin: 10px 0 6px; font-size: 18px; }

.empty p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

/* ---------- Footer ---------- */
.site-foot {
  margin-top: 32px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.site-foot p { margin: 0; }

/* ---------- Small phones ---------- */
@media (max-width: 420px) {
  .page { padding: 12px 12px 36px; }
  .site-head { padding: 12px 0 20px; }
  .site-head h1 { font-size: 21px; }
  .search-card, .gate-card, .card { padding: 15px; }
  .search-row { flex-direction: column; }
  button { width: 100%; }
  .card header { flex-direction: column; }
  .card dl { gap: 6px; }
  .card dd { font-size: 17px; }
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e1519;
    --card:      #16212a;
    --ink:       #e6edf3;
    --ink-soft:  #9bb0c0;
    --line:      #253442;

    --brand:     #2dd4bf;
    --brand-ink: #5eead4;
    --brand-bg:  #113c39;

    --ok:        #4ade80;  --ok-bg:     #12341f;
    --warn:      #fbbf24;  --warn-bg:   #3a2c0c;
    --danger:    #f87171;  --danger-bg: #3d1717;
    --muted:     #94a3b8;  --muted-bg:  #24313d;

    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
  }

  input, select { background: #0f1a21; color: var(--ink); }
  button { color: #07211e; }
  select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%239bb0c0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  }
}

/* ---------- Print (students screenshot / print results) ---------- */
@media print {
  body { background: #fff; }
  .search-card, .gate-card, .site-foot, button { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

/* ============================================================
   Admin panel
   ============================================================ */
.view-admin .page, .view-admin-login .page { max-width: 880px; }

.admin-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
}

.btn-sm {
  display: inline-block; font-size: 13.5px; font-weight: 700;
  padding: 7px 13px; border-radius: 8px; text-decoration: none;
  background: var(--brand); color: #fff; margin-inline-start: 6px;
}
@media (prefers-color-scheme: dark) { .btn-sm { color: #07211e; } }
.btn-sm.ghost { background: var(--muted-bg); color: var(--muted); }

/* KPIs */
.kpis {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 12px; text-align: center;
}
.kpi-n {
  display: block; font-size: 24px; font-weight: 800;
  color: var(--brand-ink); font-variant-numeric: tabular-nums;
}
.kpi-l { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* Panels */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.panel h2 { margin: 0 0 14px; font-size: 16.5px; font-weight: 800; }
.muted { color: var(--ink-soft); font-weight: 500; font-size: 14px; }

/* Horizontal bars */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li {
  display: grid; grid-template-columns: 92px 1fr 52px;
  align-items: center; gap: 10px; margin-bottom: 7px; font-size: 13.5px;
}
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--muted-bg); border-radius: 999px; height: 9px; overflow: hidden; }
.bar-fill  { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar-val   { text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Hourly columns */
.hours {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(24, 1fr);
  gap: 3px; height: 132px; direction: ltr;
}
.hours li { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.hour-fill { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.hour-lbl { font-size: 9.5px; color: var(--ink-soft); text-align: center; height: 14px; line-height: 14px; }

/* Table */
.admin-search { display: flex; gap: 8px; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
td.num  { font-variant-numeric: tabular-nums; font-weight: 700; }
td.when { color: var(--ink-soft); font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; font-size: 14px; }
.pager a { color: var(--brand); font-weight: 700; text-decoration: none; }
.pager span { color: var(--ink-soft); }

@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .bars li { grid-template-columns: 76px 1fr 44px; font-size: 12.5px; }
  .hours { height: 108px; }
}

/* Shown on the gate when a returning visitor is asked again for a new search */
.gate-again {
  display: inline-block;
  margin-top: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand-ink);
}

/* ============================================================
   STEP 2 — the names list (no grades shown here)
   ============================================================ */
.picker { margin-top: 22px; }

.picker-head {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}
.picker-count { color: var(--ink-soft); font-weight: 600; font-size: 13.5px; }

.notice.warn { background: var(--warn-bg); color: var(--warn); }

.name-list { list-style: none; margin: 0; padding: 0; }

.name-list li { margin-bottom: 8px; }

.name-list a {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform .06s, border-color .15s, box-shadow .15s;
}

.name-list a:hover,
.name-list a:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 2px 4px rgba(16,32,48,.08), 0 10px 28px rgba(16,32,48,.10);
  outline: none;
}
.name-list a:active { transform: translateY(1px); }

.nl-name { font-weight: 700; font-size: 16px; line-height: 1.5; }

.nl-seat {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nl-go {
  font-size: 22px;
  line-height: 1;
  color: var(--brand);
  /* the chevron points "forward", which is leftwards in RTL */
  transform: scaleX(-1);
}

/* ---------- STEP 3 — who was picked ---------- */
.picked-name {
  margin: 12px 0 2px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.5;
  color: var(--brand-ink);
}

.picked-seat {
  margin: 0 0 20px;
  font-size: 13.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------- The optional colleges question ---------- */
.opt-in {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  margin-bottom: 16px;
  background: var(--brand-bg);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14.5px;
  line-height: 1.6;
  text-align: right;
}

.opt-in input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.opt-in em { font-style: normal; color: var(--ink-soft); font-size: 13px; }

@media (prefers-color-scheme: dark) {
  .opt-in { background: var(--brand-bg); }
}

@media (max-width: 420px) {
  .name-list a { grid-template-columns: 1fr auto; padding: 12px 13px; }
  .nl-seat { grid-column: 1; font-size: 12px; }
  .nl-go { grid-row: 1 / span 2; }
}

/* Admin: colleges opt-in flag */
td .yes { color: var(--ok); font-weight: 800; font-size: 13px; }
td .no  { color: var(--ink-soft); }
