/* ============================================================
   King George's Music Academy — Staff System
   Shared design system  (app-styles.css)
   Used by every page so the look stays consistent.
   ============================================================ */

/* ---- Web fonts (loaded from Google Fonts) ---- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

/* ---- Design tokens ---- */
:root {
  --ink:        #16263D;   /* deep navy — brand + headings */
  --ink-soft:   #35506F;   /* secondary navy */
  --brass:      #B5862E;   /* regal brass accent — used sparingly */
  --brass-dark: #97701F;   /* brass hover/pressed */
  --paper:      #F4F6F9;   /* cool off-white page background */
  --surface:    #FFFFFF;   /* cards and panels */
  --line:       #E3E7EE;   /* hairline borders */
  --line-soft:  #EEF1F6;
  --text:       #1F2733;   /* body text */
  --muted:      #6B7686;   /* captions, secondary text */
  --danger:     #B23A48;   /* errors */
  --danger-bg:  #FBEDEE;
  --ok:         #2F7A5B;   /* success */
  --ok-bg:      #EAF4EF;
  --warn:       #9A6A12;   /* warnings / pending */
  --warn-bg:    #FBF3E2;

  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(22,38,61,.05), 0 8px 24px rgba(22,38,61,.06);
  --shadow-sm:  0 1px 2px rgba(22,38,61,.06);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--ink-soft); }

/* ============================================================
   LOGIN / REGISTER  (index.html)
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px 32px;
}

/* Signature element: brass monogram + musical staff lines.
   "G clef" pun on King George + music. Used once, kept quiet. */
.brand { text-align: center; margin-bottom: 26px; }
.monogram {
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  border: 1.5px solid var(--brass);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--brass);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: .5px;
}
.staff {
  height: 12px;
  margin: 0 auto 16px;
  max-width: 180px;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--line) 0, var(--line) 1px,
    transparent 1px, transparent 4px
  );
  opacity: .9;
}
.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 24px;
  color: var(--ink);
  margin: 0 0 2px;
  letter-spacing: .2px;
}
.brand-sub {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin: 0;
}

/* Tabs: Sign in / Register */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 22px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Forms */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(181,134,46,.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  width: 100%;
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover { background: #0F1C2E; }
.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--ink-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Inline messages */
.note {
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}
.note.error { background: var(--danger-bg); color: var(--danger); }
.note.ok    { background: var(--ok-bg);     color: var(--ok); }
.note.warn  { background: var(--warn-bg);   color: var(--warn); }
.note.hidden { display: none; }

.auth-foot {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 22px;
}

/* ============================================================
   APP SHELL  (admin.html, teacher.html)
   ============================================================ */
.topbar {
  background: var(--ink);
  color: #fff;
  padding: 0 22px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar .left { display: flex; align-items: center; gap: 12px; }
.topbar .mono-sm {
  width: 34px; height: 34px;
  border: 1.5px solid var(--brass);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--brass);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 14px;
}
.topbar .title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: .2px;
}
.topbar .right { display: flex; align-items: center; gap: 14px; }
.whoami { text-align: right; line-height: 1.25; }
.whoami .name { font-size: 14px; font-weight: 600; }
.whoami .role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--brass);
}
.btn-signout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-signout:hover { background: rgba(255,255,255,.1); }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 22px 64px;
}
.page-head { margin-bottom: 24px; }
.page-head h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 26px;
  color: var(--ink);
  margin: 0 0 4px;
}
.page-head p { color: var(--muted); margin: 0; font-size: 14.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
}
.card p { color: var(--muted); font-size: 14px; margin: 0 0 6px; }

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.pill.ok   { background: var(--ok-bg);   color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* Centered status screen (pending approval, etc.) */
.status-screen {
  min-height: calc(100vh - 60px);
  display: grid; place-items: center;
  padding: 24px;
}
.status-card {
  max-width: 460px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
}
.status-card .icon {
  width: 52px; height: 52px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 24px;
}
.status-card .icon.wait { background: var(--warn-bg); color: var(--warn); }
.status-card .icon.stop { background: var(--danger-bg); color: var(--danger); }
.status-card h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 8px;
}
.status-card p { color: var(--muted); font-size: 14.5px; margin: 0 0 20px; }

/* Full-page loading veil while we check who is logged in */
.veil {
  position: fixed; inset: 0;
  background: var(--paper);
  display: grid; place-items: center;
  z-index: 100;
}
.veil .spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--brass);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 520px) {
  .auth-card { padding: 32px 22px 26px; }
  .topbar { padding: 0 14px; }
  .topbar .title { font-size: 15px; }
  .page { padding: 22px 14px 48px; }
}

/* ---- Accessibility: respect reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   SESSION 2 — Dashboard stats, student list, forms, modal
   ============================================================ */

/* Topbar nav links */
.topbar .nav { display: flex; gap: 4px; margin-left: 8px; }
.topbar .nav a {
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 8px;
}
.topbar .nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar .nav a.active { background: rgba(255,255,255,.14); color: #fff; }

/* Stat tiles */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.stat .num {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 32px;
  color: var(--ink);
  line-height: 1.1;
}
.stat .num.flag { color: var(--warn); }
.stat .lbl {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* Section header row (title + action button) */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
  color: var(--ink);
  margin: 0;
}

/* Toolbar (search + filter) */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar input[type="search"] {
  flex: 1;
  min-width: 180px;
  font-family: var(--sans);
  font-size: 14.5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  background: var(--surface);
}
.toolbar input[type="search"]:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(181,134,46,.15);
}
.toolbar select {
  font-family: var(--sans);
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

/* Student list */
.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 1.6fr 1.2fr 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--paper); }
.row .s-name { font-weight: 600; color: var(--ink); font-size: 15px; }
.row .s-meta { font-size: 13px; color: var(--muted); }
.row .s-credits { font-size: 13.5px; font-weight: 600; }
.row .s-credits.low { color: var(--warn); }
.row .chev { color: var(--muted); font-size: 18px; justify-self: end; }
.row.head {
  cursor: default;
  background: var(--paper);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 700;
}
.row.head:hover { background: var(--paper); }
.row.head > div { font-weight: 700; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
}

.inactive-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  background: var(--line-soft);
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 8px;
}

/* Forms (shared by modal + detail edit) */
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; gap: 6px; }
.form-row.two { grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row label {
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.form-row input, .form-row select {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
}
.form-row input:focus, .form-row select:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(181,134,46,.15);
}
.form-row .hint { font-size: 12px; color: var(--muted); }
.fee-preview {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink-soft);
}
.fee-preview b { font-family: var(--serif); font-size: 18px; color: var(--ink); }
.owner-only-tag {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--brass);
  border: 1px solid var(--brass); border-radius: 6px;
  padding: 1px 6px; margin-left: 6px;
}

.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn-secondary {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft);
}
.btn-secondary:hover { border-color: var(--ink-soft); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #EBC7CC; }
.btn-danger:hover { background: #F6DEE1; }
.btn-sm { padding: 8px 13px; font-size: 13.5px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,28,46,.45);
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.open { display: grid; }
.modal {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(16,28,46,.3);
  max-height: 90vh; overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  font-family: var(--serif); font-weight: 600; font-size: 19px;
  color: var(--ink); margin: 0;
}
.modal-x {
  border: 0; background: transparent; font-size: 22px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.modal-x:hover { background: var(--paper); color: var(--ink); }
.modal-body { padding: 20px 22px 22px; }

/* Detail page header */
.detail-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 4px;
}
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 600;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--ink-soft); }
.credit-box {
  display: flex; align-items: baseline; gap: 10px;
}
.credit-box .big {
  font-family: var(--serif); font-weight: 600; font-size: 40px; color: var(--ink);
}
.credit-box .big.low { color: var(--warn); }

@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1.4fr 1fr auto; }
  .row .s-credits { display: none; }
  .form-row.two { grid-template-columns: 1fr; }
}
