/* ============================================================================
   National Aviation College — light dashboard theme (college brand colors)
   Brand: blue #1673a8 / #3fabd7 · gold #978347 / #c5af5c
   ========================================================================== */
:root {
  /* Official NAC brand colors (Brand Guideline 2024): blue #00539C, gold #A67C00 */
  --brand: #00539c;
  --brand-dark: #003f78;
  --brand-light: #2e7bc4;
  --brand-tint: #e7f0f9;
  --gold: #a67c00;
  --gold-light: #c99e2e;
  --gold-tint: #f7f0dd;

  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #15233a;
  --muted: #64748b;
  --line: #e3e8ef;
  --ok: #1e9e5a;
  --err: #d23b34;

  --radius: 14px;
  --shadow: 0 6px 24px rgba(21, 53, 90, 0.08);
  --shadow-sm: 0 1px 3px rgba(21, 53, 90, 0.06);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }

/* Respect users who prefer reduced motion (UX guideline: Accessibility/Animation). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
input, select, textarea, button { font-size: 16px; font-family: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand-light); outline-offset: 2px; border-radius: 6px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 600; padding: 11px 18px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; min-height: 42px;
  transition: background .15s, box-shadow .15s, transform .05s; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(22, 115, 168, .25); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--brand-tint); border-color: var(--brand-light); color: var(--brand-dark); }
.btn.danger { background: var(--err); color: #fff; }
.btn.danger:hover { background: #b32a24; }
.btn.small { padding: 8px 13px; font-size: 13px; min-height: 36px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Eye-catching "update your info" call-to-action */
.update-cta {
  display: flex; align-items: center; gap: 14px;
  margin-top: 20px; padding: 14px 18px;
  border: 1px solid var(--gold-light); border-left: 5px solid var(--gold);
  border-radius: 12px; background: var(--gold-tint);
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.update-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow); background: #f3e8c8; }
.update-cta-icon {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center;
  font-size: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm);
}
.update-cta-text { display: flex; flex-direction: column; line-height: 1.3; }
.update-cta-text strong { color: var(--gold); font-size: 15px; }
.update-cta-text span { color: var(--muted); font-size: 14px; }
.update-cta-arrow { margin-left: auto; font-size: 22px; color: var(--gold); transition: transform .12s ease; }
.update-cta:hover .update-cta-arrow { transform: translateX(4px); }

.muted { color: var(--muted); font-size: 14px; }
.hint { font-size: 12px; }
.warn-text { color: var(--gold); font-weight: 600; }

/* ── Top bar (public pages) ───────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(100deg, var(--brand-dark), var(--brand));
  color: #fff; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30; box-shadow: 0 2px 16px rgba(17, 93, 135, .28);
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center;
  background: rgba(255,255,255,.16); border-radius: 12px; }
.brand-logo { width: 50px; height: 50px; border-radius: 12px; background: #fff; padding: 5px;
  object-fit: contain; box-shadow: 0 2px 8px rgba(0,0,0,.18); flex: 0 0 auto; }
.brand-text strong { display: block; font-size: 18px; letter-spacing: .2px; }
.brand-text small { color: #d6e8f3; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.link-light { color: #e7f2f9; text-decoration: none; font-size: 14px; font-weight: 600; }
.link-light:hover { color: #fff; }

/* ── Cards / forms (public) ───────────────────────────────────────────────── */
.card {
  max-width: 660px; margin: 26px auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px;
}
.card.narrow { max-width: 420px; }
h2 { margin: 0 0 16px; font-size: 20px; color: var(--brand-dark); }

form { display: flex; flex-direction: column; gap: 15px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.row { display: flex; gap: 15px; }
.row > label, .row > .btn { flex: 1; }
input, select, textarea {
  font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,115,168,.15);
}
select:disabled { background: var(--surface-2); color: var(--muted); }

/* Step indicator */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 22px; counter-reset: step; }
.steps li { flex: 1; text-align: center; font-size: 13px; color: var(--muted); padding: 8px 4px;
  border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); counter-increment: step; }
.steps li::before { content: counter(step); display: inline-block; margin-right: 6px; width: 20px; height: 20px;
  line-height: 20px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-dark); font-weight: 700; font-size: 12px; }
.steps li.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.steps li.active::before { background: #fff; color: var(--brand); }
.steps li.done { background: #e7f6ee; color: var(--ok); border-color: #c9ecd8; }
.steps li.done::before { content: "✓"; background: var(--ok); color: #fff; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; border: 1px solid; white-space: pre-wrap; }
.alert.error { background: #fdeceb; border-color: #f4c7c4; color: var(--err); }
.alert.info { background: var(--brand-tint); border-color: #c5e2f1; color: var(--brand-dark); }

/* Preview / done */
.preview { margin-bottom: 18px; }
.pv-fields { margin: 0; display: grid; gap: 10px; }
.pv-fields div { display: grid; grid-template-columns: 140px 1fr; gap: 8px; align-items: baseline; }
.pv-fields dt { color: var(--muted); font-size: 13px; }
.pv-fields dd { margin: 0; font-weight: 600; }
.done { text-align: center; padding: 16px 0; }
.done-mark { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 12px; background: #e7f6ee;
  color: var(--ok); display: grid; place-items: center; font-size: 34px; font-weight: 700; }
.foot { text-align: center; color: var(--muted); padding: 10px 0 28px; }

/* ════════════════════════════════════════════════════════════════════════════
   ADMIN — sidebar dashboard
   ════════════════════════════════════════════════════════════════════════ */
body.admin { background: var(--bg); }

/* Login screen */
#login.login-screen, #login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--brand-tint), var(--bg)); }
#login .card { margin: 0; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.login-brand img { width: 46px; height: 46px; border-radius: 11px; background: #fff; padding: 4px; box-shadow: var(--shadow-sm); }
.login-brand strong { font-size: 16px; color: var(--brand-dark); }

/* App shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.side-brand img { width: 42px; height: 42px; border-radius: 11px; object-fit: contain; }
.side-brand .st { font-weight: 800; color: var(--brand-dark); line-height: 1.1; }
.side-brand .sub { font-size: 11px; color: var(--muted); font-weight: 600; }

/* Nav (reuses .tabs/.tab from the old markup, now vertical) */
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tab {
  font: inherit; font-weight: 600; font-size: 14.5px; text-align: left; width: 100%;
  padding: 11px 14px; border: none; background: transparent; color: var(--muted);
  border-radius: 11px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s; position: relative;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.active {
  background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(22,115,168,.32);
}
.tab.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--gold); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--gold); color: #fff; font-size: 12px; margin-left: auto; }
.tab.active .badge { background: #fff; color: var(--brand-dark); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.link-muted { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; padding: 9px 14px; border-radius: 10px; }
.link-muted:hover { background: var(--surface-2); color: var(--brand-dark); }

/* Content area */
.content { flex: 1; min-width: 0; padding: 22px 26px 40px; display: grid; gap: 18px; align-content: start; }
.content-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.content-head h1 { margin: 0; font-size: 22px; color: var(--ink); }

.admin-card, .content > section, .content .card { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; max-width: none; margin: 0; min-width: 0; }
.content > div { display: grid; gap: 18px; min-width: 0; }

.filters-head, .results-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.small-select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

/* List toolbar */
.list-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1 1 280px; min-width: 200px; }
.search-wrap .search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .55; }
.search-wrap input { padding-left: 36px; }
.toolbar-actions { display: flex; gap: 8px; }
#filters-toggle .chevron { font-size: 12px; }
.filter-count { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; margin-left: 2px; }

/* Collapsible panels */
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 15px; margin-bottom: 14px; background: var(--surface-2); }
.export-panel { background: var(--gold-tint); border-color: #e6dcc0; }
.panel-title { margin: 0 0 12px; font-weight: 600; color: var(--brand-dark); font-size: 14px; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.panel-foot .hint { margin: 0; }
.export-btns { display: flex; gap: 8px; }

.filter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.filter-grid .full { grid-column: 1 / -1; }
.filter-grid label, .presence-grid label { font-size: 13px; }
.presence-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 12px; align-items: center;
  margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.presence-title { grid-column: 1 / -1; font-weight: 700; color: var(--brand-dark); font-size: 14px; }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; flex-direction: row; }
.chk input { width: auto; accent-color: var(--brand); }

.count { font-weight: 700; color: var(--brand-dark); background: var(--brand-tint); padding: 4px 12px; border-radius: 999px; font-size: 14px; }

/* Table */
.table-wrap { border: 1px solid var(--line); border-radius: 12px; overflow-x: hidden; }
#results-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
#results-table th, #results-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line);
  white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
#results-table .col-id, #results-table .col-fan, #results-table .col-phone,
#results-table .col-via, #results-table .col-date, #results-table td.flags { white-space: nowrap; }
#results-table thead th { background: var(--brand-tint); color: var(--brand-dark); font-weight: 700; }
#results-table tbody tr.srow { cursor: pointer; transition: background .12s; }
#results-table tbody tr.srow:hover { background: var(--brand-tint); }
#results-table td.empty { text-align: center; color: var(--muted); padding: 28px; }

@media (max-width: 1100px) { .col-id { display: none; } }
@media (max-width: 1000px) { .col-date { display: none; } }
@media (max-width: 880px)  { .col-fan { display: none; } }
@media (max-width: 800px)  { .col-via { display: none; } }
@media (max-width: 720px)  { .col-time { display: none; } }
@media (max-width: 620px)  { .col-level { display: none; } }
@media (max-width: 520px)  { .col-phone { display: none; } }
@media (max-width: 430px)  { .col-studentid { display: none; } }

body.hide-phone .col-phone { display: none; }
body.hide-fan .col-fan { display: none; }

.via { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.via.tg { background: var(--brand-tint); color: var(--brand-dark); }
.via.web { background: var(--gold-tint); color: var(--gold); }
.flags { display: flex; gap: 4px; }
.dot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff; }
.dot.on { background: var(--ok); }
.dot.off { background: #cfd8e3; color: #7c8aa0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(17, 35, 58, .5); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; padding: 24px; position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; border: none; background: var(--brand-tint); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px; color: var(--brand-dark); }
/* Confirm / prompt dialog */
.dialog-card { max-width: 420px; }
.dialog-card h3 { margin: 0 0 8px; }
.dialog-card #dialog-message { margin: 0 0 16px; white-space: pre-line; }
.dialog-input { width: 100%; margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; box-sizing: border-box; }
.dialog-input[hidden] { display: none; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.dialog-card .btn[hidden] { display: none; }
#dialog { z-index: 60; }
.detail-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.detail-head h2 { margin: 0 0 4px; }
.detail-photo { width: 96px; height: 116px; object-fit: cover; border-radius: 11px; border: 1px solid var(--line); background: var(--brand-tint); }
.detail-photo.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.detail-actions { display: flex; justify-content: flex-end; margin: -6px 0 12px; }
.detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 0; }
.detail-fields div { display: grid; grid-template-columns: 120px 1fr; gap: 8px; align-items: baseline; }
.detail-fields dt { color: var(--muted); font-size: 13px; }
.detail-fields dd { margin: 0; font-weight: 600; word-break: break-word; }

/* Requests + broadcast + admins */
.requests-list, .bc-list, .admins-list { display: grid; gap: 13px; }
.requests-list .empty, .bc-list .empty, .admins-list .empty { text-align: center; padding: 22px; }
.request-card, .bc-card, .admin-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.request-card.clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.request-card.clickable:hover, .request-card.clickable:focus-visible { border-color: var(--brand); box-shadow: var(--shadow); outline: none; }
.req-summary { margin: 0 0 8px; }
.req-more { color: var(--brand); }
.req-diff-title { margin: 18px 0 8px; font-size: 15px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-head h2 { margin: 0; }
.request-head, .bc-card-head, .admin-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.status-badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; text-transform: capitalize; }
.status-badge.pending, .status-badge.sending { background: var(--gold-tint); color: var(--gold); }
.status-badge.approved, .status-badge.completed { background: #e7f6ee; color: var(--ok); }
.status-badge.rejected, .status-badge.cancelled { background: #fdeceb; color: var(--err); }
.status-badge.draft { background: var(--surface-2); color: var(--muted); }
table.diff { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 10px; }
table.diff th, table.diff td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.diff thead th { color: var(--muted); font-size: 12px; }
table.diff tr.changed td { background: var(--gold-tint); font-weight: 600; }
.request-actions { display: flex; gap: 8px; justify-content: flex-end; }

.bc-messages-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; }
.bc-message { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface-2); }
.bc-message-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.bc-message-tools { display: flex; gap: 8px; align-items: center; }
.bc-parse { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; }
.bc-text { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.bc-progress { height: 8px; background: var(--brand-tint); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bc-bar { height: 100%; background: var(--brand); transition: width .4s; }
.bc-stats { font-size: 13px; }

.perm-set { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; margin: 6px 0 12px; }
.perm-set legend { font-weight: 600; color: var(--brand-dark); padding: 0 6px; font-size: 14px; }
.perm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 14px; }
.scope-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
#tab-tools .card { margin-bottom: 0; }
#restoreFile { display: block; margin: 12px 0; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: sticky; top: 0; z-index: 30;
    flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; overflow: visible; }
  .side-brand { border: none; margin: 0; padding: 0; flex: 0 0 auto; }
  .side-brand .sub { display: none; }
  .tabs { flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { width: auto; flex: 0 0 auto; white-space: nowrap; padding: 9px 13px; }
  .tab.active::before { display: none; }
  .badge { margin-left: 4px; }
  .side-foot { margin: 0; flex-direction: row; padding: 0; border: none; flex: 0 0 auto; }
  .link-muted { display: none; }
  .content { padding: 16px 14px 36px; }
}
@media (max-width: 860px) {
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .presence-grid { grid-template-columns: repeat(3, 1fr); }
  .perm-grid { grid-template-columns: repeat(2, 1fr); }
  .scope-grid { grid-template-columns: 1fr; }
  .detail-fields { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .row { flex-direction: column; }
  .card { margin: 14px; padding: 18px; }
  .filter-grid { grid-template-columns: 1fr; }
  .presence-grid { grid-template-columns: repeat(2, 1fr); }
  .content-head h1 { font-size: 19px; }
  .modal-card { padding: 16px; }
}
