/* ================================================
   LearnLink — Unified Design System
   ================================================ */

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

:root {
  /* ── Paper backgrounds (unchanged — these are perfect) */
  --cream:      #faf7f2;
  --cream-dark: #f0ebe0;
  --parchment:  #e2d9c8;
  --white:      #ffffff;

  /* ── Ink (text) — slightly warmer black */
  --ink:        #1a1310;
  --ink-soft:   #3d3530;
  --ink-muted:  #7a6f66;

  /* ── Kraft (primary brand) — richer, deeper */
  --kraft:       #7c3410;
  --kraft-mid:   #a04215;
  --kraft-light: #fdf0e0;
  --kraft-border: #f5c99a;

  /* ── Forest green (new accent — links, active, success) */
  --forest:       #2d6a4f;
  --forest-mid:   #40916c;
  --forest-light: #edf7f2;
  --forest-border:#b7e4c7;

  /* ── Status colours */
  --red:        #b91c1c;
  --red-light:  #fef2f2;
  --amber:      #b45309;
  --amber-light:#fffbeb;

  /* ── Legacy aliases (keep pages working) */
  --blue:       var(--forest);
  --blue-light: var(--forest-light);
  --green:      var(--forest);
  --green-light:var(--forest-light);

  /* ── Shadows — warmer tint */
  --shadow-sm:  0 1px 3px rgba(60,30,10,.07), 0 1px 2px rgba(60,30,10,.05);
  --shadow:     0 4px 14px rgba(60,30,10,.09), 0 2px 4px rgba(60,30,10,.05);
  --shadow-lg:  0 14px 36px rgba(60,30,10,.12), 0 4px 10px rgba(60,30,10,.07);

  /* ── Radii */
  --radius:    14px;
  --radius-sm:  8px;
  --radius-lg: 20px;
  --line:      rgba(0,0,0,.09);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────── */
h1, h2, h3, h4 {
  font-family: 'Lora', Georgia, serif;
  line-height: 1.25;
  color: var(--ink);
}
h1 { font-size: clamp(22px, 4vw, 32px); font-weight: 700; }
h2 { font-size: clamp(18px, 3vw, 26px); font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }
p  { color: var(--ink-soft); }

a { color: var(--forest); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--forest-mid); }

/* ── Topbar Nav ──────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,247,242,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--parchment);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-logo { height: 36px; width: auto; }
.brand-name {
  font-family: 'Lora', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a:not(.btn) {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav a:hover { background: var(--cream-dark); color: var(--ink); }
.nav a.active { background: var(--forest-light); color: var(--forest); border: 1px solid var(--forest-border); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--kraft);
  color: #fff;
  box-shadow: 0 2px 6px rgba(124,52,16,.25);
}
.btn-primary:hover { background: var(--kraft-mid); color: #fff; box-shadow: 0 4px 12px rgba(124,52,16,.3); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--parchment);
  color: var(--ink-soft);
}
.btn-outline:hover { border-color: var(--kraft); background: var(--kraft-light); color: var(--kraft); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--cream-dark); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Page Layout ─────────────────────────────── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.page-head {
  margin-bottom: 28px;
}
.page-head h1 { margin-bottom: 6px; }
.page-head p  { color: var(--ink-muted); font-size: 15px; }

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--parchment);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: 24px; }
.card-body + .card-body { border-top: 1px solid var(--cream-dark); }

/* ── Form elements ───────────────────────────── */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

label.lbl {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  font-family: 'DM Sans', sans-serif;
  border: 1.5px solid var(--parchment);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-muted); }
.input:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(45,106,79,.12);
}
.input.is-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(185,28,28,.08);
}

textarea.input { resize: vertical; min-height: 90px; }

.error-msg {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
}

/* ── Alerts ──────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-success { background: var(--forest-light); color: var(--forest);  border: 1px solid var(--forest-border); }
.alert-error   { background: var(--red-light);    color: var(--red);     border: 1px solid #fecaca; }
.alert-info    { background: var(--kraft-light);  color: var(--kraft);   border: 1px solid var(--kraft-border); }

/* ── Badge / Pill ────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--kraft-light);
  color: var(--kraft);
  text-transform: capitalize;
}
.badge-blue  { background: var(--forest-light); color: var(--forest); border: 1px solid var(--forest-border); }
.badge-green { background: var(--forest-light); color: var(--forest); border: 1px solid var(--forest-border); }

/* ── Table ───────────────────────────────────── */
.tbl-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--parchment);
  background: var(--white);
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl thead th {
  background: var(--cream-dark);
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--parchment);
  white-space: nowrap;
}
.tbl tbody tr {
  border-bottom: 1px solid var(--cream-dark);
  transition: background .12s;
}
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background: var(--cream); }
.tbl tbody tr.selected { background: var(--kraft-light); }
.tbl td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--ink-soft);
}
.tbl td .title-link {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.tbl td .title-link:hover { color: var(--forest); text-decoration: underline; }

/* ── Stat cards ──────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--cream-dark);
  border: 1px solid var(--parchment);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-muted);
}
.stat-card .stat-value {
  font-family: 'Lora', serif;
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--ink);
}

/* ── Discussion panel ────────────────────────── */
.split-layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 860px) { .split-layout { grid-template-columns: 1fr; } }

.panel-sticky { position: sticky; top: 80px; }

.panel-header {
  background: var(--ink);
  color: var(--white);
  padding: 13px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-header .panel-title { font-weight: 700; font-size: 15px; }
.panel-header .panel-sub   { font-size: 12px; color: #a8a29e; margin-top: 2px; }

.panel-frame {
  width: 100%;
  height: 560px;
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--cream);
  display: block;
  border: 1px solid var(--parchment);
  border-top: none;
}

.panel-placeholder {
  height: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 14px;
  border: 1px solid var(--parchment);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--cream-dark);
}
.panel-placeholder .icon { font-size: 36px; opacity: .4; }

/* ── Search toolbar ──────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.search-bar .input { flex: 1; }

/* ── Auth card layout ────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--cream);
}
.auth-logo { height: 72px; margin-bottom: 20px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--parchment);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}
.auth-card h2 {
  font-size: 26px;
  margin-bottom: 4px;
}
.auth-card .sub {
  color: var(--ink-muted);
  font-size: 14px;
  margin-bottom: 24px;
}
.auth-footer {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  font-size: 14px;
}
.auth-footer a { font-weight: 700; }
.auth-footer .muted-link { color: var(--ink-muted); font-weight: 500; }

/* ── Nav search ──────────────────────────────── */
.nav-search {
  display: flex;
  align-items: center;
  background: var(--cream-dark);
  border: 1px solid var(--parchment);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.nav-search input {
  border: none;
  background: transparent;
  padding: 7px 12px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  outline: none;
  width: 170px;
}
.nav-search input::placeholder { color: var(--ink-muted); }
.nav-search button {
  background: var(--kraft);
  border: none;
  color: #fff;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background .15s;
}
.nav-search button:hover { background: var(--kraft-mid); }

/* ── Divider ─────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--parchment);
  margin: 20px 0;
}

/* ── Upload page ─────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--parchment);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  background: var(--cream-dark);
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--forest);
  background: var(--forest-light);
}
.upload-zone input[type="file"] {
  display: none;
}
.upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-label { font-weight: 700; font-size: 15px; }
.upload-hint  { font-size: 13px; color: var(--ink-muted); margin-top: 4px; }
.upload-selected { font-size: 13px; color: var(--forest); font-weight: 700; margin-top: 8px; }

/* ── Footer ──────────────────────────────────── */
.footer {
  border-top: 1px solid var(--parchment);
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-muted);
}

/* ── Note preview page ───────────────────────── */
.preview-box {
  border: 1px solid var(--parchment);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--cream-dark);
  margin-top: 16px;
}
.preview-box iframe, .preview-box img {
  width: 100%;
  border: none;
  display: block;
}
.preview-box iframe { height: 680px; }
.preview-box img    { max-width: 100%; }
.preview-box pre {
  padding: 20px;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--ink-soft);
}
.preview-unsupported {
  padding: 32px;
  text-align: center;
  color: var(--ink-muted);
}

/* ── Responsive nav ──────────────────────────── */
@media (max-width: 700px) {
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .nav { gap: 4px; }
  .nav-search input { width: 120px; }
  .page { padding: 20px 16px 48px; }
  .auth-card { padding: 28px 20px; }
}

.nav .btn-primary {
  color: #ffffff !important;
}

.nav .btn-primary:hover {
  color: #ffffff !important;
}