/* ═══════════════════════════════════════════════════
   Tutor — Scholar's Study Design System
   Fonts: Fraunces (display) + Plus Jakarta Sans (body)
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400&family=Plus+Jakarta+Sans:wght@400;500;600&display=swap');

/* ─── Tokens ──────────────────────────────────────── */
:root {
  --paper:        #F7F4EE;
  --surface:      #FFFFFF;
  --surface-2:    #F9F7F3;
  --ink:          #1A1714;
  --ink-mid:      #4A4640;
  --ink-muted:    #7C776F;
  --ink-faint:    #B6B0A8;
  --green:        #1E5C38;
  --green-hover:  #185030;
  --green-light:  #EBF3EE;
  --green-border: #C4DDD0;
  --red:          #B23B3B;
  --red-light:    #FDF0F0;
  --amber:        #92500E;
  --amber-light:  #FEF5E7;
  --border:       #E3DDD3;
  --border-dark:  #C7C1B7;
  --shadow-xs:    0 1px 2px rgba(26, 23, 20, 0.06);
  --shadow-sm:    0 1px 4px rgba(26, 23, 20, 0.08), 0 1px 2px rgba(26, 23, 20, 0.04);
  --shadow:       0 3px 12px rgba(26, 23, 20, 0.10), 0 1px 3px rgba(26, 23, 20, 0.06);
  --shadow-lg:    0 8px 28px rgba(26, 23, 20, 0.12), 0 2px 8px rgba(26, 23, 20, 0.06);
  --radius:       9px;
  --radius-sm:    6px;
  --radius-lg:    14px;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --nav-h:        56px;
}

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

/* ─── Base ────────────────────────────────────────── */
html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Animations ──────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Navigation ──────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--green);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
  flex: 1;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-name {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.72);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-role {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
}

.nav-admin {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.nav-admin:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-signout {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.nav-signout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

/* ─── Main content ────────────────────────────────── */
main {
  max-width: 960px;
  margin: 2.25rem auto;
  padding: 0 1.25rem;
  animation: fade-up 0.3s ease both;
}

/* ─── Page header ─────────────────────────────────── */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--ink);
}

.page-head-meta {
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Section heading ─────────────────────────────── */
.section-head {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 1rem;
}

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

/* ─── Course grid ─────────────────────────────────── */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
}
.course-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-dark);
  transform: translateY(-1px);
}

.course-card-subject {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
}

.course-card-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.3;
}

.course-card-meta {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: auto;
  padding-top: 0.5rem;
}

/* ─── Empty state ─────────────────────────────────── */
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-xs);
}

.empty-icon {
  width: 52px;
  height: 52px;
  background: var(--green-light);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  color: var(--green);
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.empty-text {
  font-size: 0.875rem;
  color: var(--ink-muted);
  max-width: 300px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

/* ─── Table ───────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #F2EFE8;
  font-size: 0.9rem;
  color: var(--ink);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FDFCF9; }

/* ─── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover  { background: var(--green-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: var(--surface);
  color: var(--ink-mid);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-faint); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: transparent;
  color: var(--ink-muted);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--red);
  border: 1px solid #E8C0C0;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-danger:hover { background: var(--red-light); }

/* ─── Button size variant ─────────────────────────── */
.btn-sm { padding: 0.38rem 0.8rem; font-size: 0.8rem; }

/* ─── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-admin   { background: var(--green-light); color: var(--green); }
.badge-student { background: var(--amber-light); color: var(--amber); }

/* ─── Status pills ────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}
.pill-queued     { color: var(--amber); background: var(--amber-light); }
.pill-processing { color: #1852A4; background: #EDF2FC; }
.pill-ready      { color: var(--green); background: var(--green-light); }
.pill-error      { color: var(--red);   background: var(--red-light); }

/* ─── Forms ───────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.1rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-mid);
  letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 92, 56, 0.1);
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--ink-faint);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237C776F' d='M6 8L1.5 3.5h9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

.form-file {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.15s;
}
.form-file:hover { border-color: var(--green); color: var(--ink); }

.form-hint {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.15rem;
}

/* ─── Flash messages ──────────────────────────────── */
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.flash-error   { background: var(--red-light);   border: 1px solid #EAC8C8; color: var(--red); }
.flash-success { background: var(--green-light);  border: 1px solid var(--green-border); color: var(--green); }
.flash-info    { background: #EDF2FC; border: 1px solid #C0D4F5; color: #1852A4; }

/* ─── Divider ─────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

/* ─── Dialog / Modal ──────────────────────────────── */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  outline: none;
}

dialog::backdrop {
  background: rgba(26, 23, 20, 0.45);
  backdrop-filter: blur(2px);
}

dialog > form {
  padding: 1.75rem 1.75rem 1.5rem;
}

.dlg-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ─── Course subject label ────────────────────────── */
.course-subject-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 0.2rem;
}

/* ─── Responsive (base) ───────────────────────────── */
@media (max-width: 600px) {
  main { margin: 1.25rem auto; }
  .page-head h1 { font-size: 1.6rem; }
  .course-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  nav { padding: 0 1rem; }
  .nav-name { display: none; }
}
