@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600;700&display=swap');

/* ─── Custom Properties ─────────────────────────────────────────────────── */

:root {
  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;
  --font-sans: 'DM Sans', system-ui, sans-serif;

  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f9f9fa;
  --border: #e4e4e7;
  --border-strong: #d1d1d6;
  --text: #18181b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  --accent: #27272a;
  --accent-hover: #3f3f46;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

[data-theme="parchment"] {
  --bg: #faf7f2;
  --surface: #fffef9;
  --surface-2: #f5ede0;
  --border: #ddd5c8;
  --border-strong: #c8b89a;
  --text: #2d2926;
  --text-muted: #7a6e65;
  --text-faint: #b0a499;
  --accent: #5c3d1e;
  --accent-hover: #7a5230;
  --gold: #c5a87d;
  --cream: #f5ede0;
  --ink: #1a1208;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }

/* ─── Typography ─────────────────────────────────────────────────────────── */

.serif { font-family: var(--font-serif); }
.mono  { font-family: var(--font-mono); }
h1, h2, h3, h4 { font-family: var(--font-sans); font-weight: 600; }

[data-theme="parchment"] h1,
[data-theme="parchment"] h2 { font-family: var(--font-serif); }

/* ─── Shared Header ──────────────────────────────────────────────────────── */

.site-header {
  width: 100%;
  background: #1c1c1c;
  color: #f0f0f0;
  padding: .8rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  position: sticky; top: 0; z-index: 200;
}
.site-header .brand { font-family: var(--font-serif); font-size: 1.2rem; color: #f0f0f0; text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: .5rem; }

[data-theme="parchment"] .site-header { background: #2d2926; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500;
  cursor: pointer; border: none; transition: background .15s, transform .1s, box-shadow .15s; text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: #aaa; }
.btn-ghost:hover { color: #f0f0f0; background: rgba(255,255,255,.08); }
.btn-outline-header { background: transparent; border: 1px solid #4a4a4a; color: #ccc; padding: .38rem .9rem; font-size: .85rem; border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, color .15s; }
.btn-outline-header:hover { border-color: #999; color: #f5f5f5; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-full { width: 100%; }
.btn-danger { background: #991b1b; color: #fff; }
.btn-danger:hover { background: #7f1d1d; }

/* ─── Card ───────────────────────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 1.5rem; }
.card-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-weight: 600; font-size: 1rem; }

/* ─── Form ───────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .82rem; font-weight: 500; color: var(--text-muted); margin-bottom: .35rem; }
.form-control { width: 100%; padding: .55rem .85rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: .95rem; color: var(--text); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; font-family: var(--font-sans); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(39,39,42,.08); }
.form-error { color: #b91c1c; font-size: .83rem; margin-top: .35rem; }
.form-error-box { background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius-sm); padding: .5rem .75rem; color: #b91c1c; font-size: .85rem; margin-bottom: .75rem; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(3px); }
.modal-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2rem 2.5rem 2.5rem; width: 100%; max-width: 440px; position: relative; }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.4rem; color: var(--text-faint); cursor: pointer; padding: .2rem .4rem; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--surface-2); }

/* ─── Badge ──────────────────────────────────────────────────────────────── */

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-admin   { background: #18181b; color: #f4f4f5; }
.badge-teacher { background: #3f3f46; color: #e4e4e7; }
.badge-student { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */

.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: #18181b; color: #f4f4f5; padding: .75rem 1.25rem; border-radius: var(--radius-md); font-size: .875rem; box-shadow: var(--shadow-lg); opacity: 1; transition: opacity .3s; min-width: 220px; }
.toast.toast-success { border-left: 3px solid #22c55e; }
.toast.toast-error   { border-left: 3px solid #ef4444; }
.toast.toast-info    { border-left: 3px solid #6b7280; }

/* ─── Tab Bar ────────────────────────────────────────────────────────────── */

.tab-bar { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn { flex: none; padding: .6rem 1.2rem; font-size: .9rem; font-weight: 500; color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; transition: color .15s, border-color .15s; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--text); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Table ──────────────────────────────────────────────────────────────── */

.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th { background: var(--surface-2); color: var(--text-muted); font-weight: 600; padding: .6rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--surface-2); }

/* ─── User Pill ──────────────────────────────────────────────────────────── */

.user-pill { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: #d0d0d0; }
#user-name-display { font-weight: 500; color: #e0e0e0; }

/* ─── Sidebar Layout ─────────────────────────────────────────────────────── */

.app-layout { display: flex; height: calc(100vh - 52px); }
.sidebar { width: 240px; min-width: 240px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-header { padding: 1rem; font-weight: 600; font-size: .875rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.sidebar-item { padding: .6rem 1rem; font-size: .9rem; cursor: pointer; border-radius: 0; display: flex; align-items: center; gap: .5rem; color: var(--text); transition: background .12s; }
.sidebar-item:hover, .sidebar-item.active { background: var(--surface-2); }
.main-content { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* ─── Utilities ──────────────────────────────────────────────────────────── */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.mt-1{margin-top:.25rem} .mt-2{margin-top:.5rem} .mt-3{margin-top:.75rem} .mt-4{margin-top:1rem}
.mb-1{margin-bottom:.25rem} .mb-2{margin-bottom:.5rem} .mb-3{margin-bottom:.75rem} .mb-4{margin-bottom:1rem}
.p-2{padding:.5rem} .p-3{padding:.75rem} .p-4{padding:1rem}
.text-sm { font-size: .875rem; } .text-xs { font-size: .75rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
