/* === EdAIcate Design Tokens === */
:root {
  --bg: #faf6f0;
  --bg-alt: #f0ebe1;
  --surface: #ffffff;
  --fg: #1c2b1c;
  --fg-muted: #5a6b5a;
  --fg-faint: #8a9b8a;
  --accent: #2d6a2d;
  --accent-warm: #c47b23;
  --border: #d5ddd0;
  --role-student: #4a7c59;
  --role-parent: #7a4a8c;
  --role-teacher: #2d6a2d;
  --danger: #c0392b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .wordmark {
  font-family: 'Fraunces', Georgia, serif;
}

/* === NAVBAR === */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 246, 240, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto;
  padding: 0.875rem 2rem;
  display: flex; align-items: center; gap: 1rem;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

.tagline { font-size: 0.8125rem; color: var(--fg-faint); }
.role-badge {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.role-badge.teacher { background: rgba(45,106,45,0.12); color: var(--role-teacher); }
.role-badge.parent  { background: rgba(122,74,140,0.12);  color: var(--role-parent);  }

/* === LAYOUT === */
.page-wrap { max-width: 1120px; margin: 0 auto; padding: 2rem 2rem 4rem; }

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1.1rem; border-radius: 6px; border: none; cursor: pointer;
  font-size: 0.9375rem; font-weight: 500; text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #245a24; }
.btn-secondary { background: var(--bg-alt); color: var(--fg); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: none; color: var(--fg-muted); padding: 0.5rem 0.75rem; }
.btn-ghost:hover { color: var(--fg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { font-size: 0.8125rem; padding: 0.3rem 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === FORMS === */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1rem; }
label { font-size: 0.875rem; font-weight: 500; color: var(--fg-muted); }
input, select, textarea {
  padding: 0.6rem 0.9rem; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 1rem; font-family: inherit;
  background: var(--surface); color: var(--fg);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }
.form-error { color: var(--danger); font-size: 0.875rem; }

/* === CARDS === */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem;
}
.card-sm { padding: 1rem; }
.card-title { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; color: var(--fg); }

/* === STUDENT LIST === */
.student-card {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  margin-bottom: 0.75rem; transition: box-shadow 0.15s;
}
.student-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.07); }
.student-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.125rem;
}
.student-info { flex: 1; min-width: 0; }
.student-name { font-weight: 600; font-size: 1rem; }
.student-grade { font-size: 0.8125rem; color: var(--fg-muted); }

/* === GRADE TABLE === */
.data-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.data-table th { text-align: left; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg-faint); padding: 0.5rem 0.75rem; border-bottom: 2px solid var(--border); }
.data-table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.9375rem; vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(0,0,0,0.02); }
.grade-score { font-weight: 700; font-size: 1rem; }
.grade-date { color: var(--fg-muted); font-size: 0.8125rem; white-space: nowrap; }
.grade-note { color: var(--fg-muted); font-size: 0.875rem; margin-top: 0.2rem; }

/* === SECTIONS === */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { font-size: 1.0625rem; font-weight: 600; color: var(--fg); }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* === LOG PANELS === */
.log-entry { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.log-entry:last-child { border-bottom: none; }
.log-entry-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.2rem; }
.log-entry-text { font-size: 0.9375rem; color: var(--fg); }
.log-entry-date { font-size: 0.75rem; color: var(--fg-faint); }
.log-type { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 4px; display: inline-block; }
.log-type.achievement { background: rgba(74,124,89,0.12); color: var(--role-student); }
.log-type.improvement { background: rgba(196,55,43,0.1); color: var(--danger); }
.log-type.behavior { background: rgba(196,123,35,0.12); color: var(--accent-warm); }

/* === FLASH === */
.flash { padding: 0.75rem 1rem; border-radius: 7px; margin-bottom: 1rem; font-size: 0.9375rem; }
.flash-error { background: rgba(192,57,43,0.1); color: var(--danger); border: 1px solid rgba(192,57,43,0.2); }
.flash-success { background: rgba(45,106,45,0.1); color: var(--accent); border: 1px solid rgba(45,106,45,0.2); }

/* === ADD-FORM INLINE === */
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; background: var(--bg-alt); padding: 1rem; border-radius: 8px; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 120px; }

/* === LINKED PARENTS === */
.parent-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8125rem; color: var(--role-parent); background: rgba(122,74,140,0.08); padding: 0.2rem 0.6rem; border-radius: 999px; margin-right: 0.4rem; margin-bottom: 0.4rem; }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--fg-muted); }
.empty-state p { margin-bottom: 1rem; }

/* === AUTH PAGES === */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,0.06); }
.auth-title { font-size: 1.75rem; font-weight: 400; margin-bottom: 0.5rem; text-align: center; color: var(--fg); }
.auth-subtitle { font-size: 0.9375rem; color: var(--fg-muted); text-align: center; margin-bottom: 2rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; color: var(--fg-muted); }
.auth-footer a { color: var(--accent); font-weight: 500; }

/* === GRID === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* === TOPBAR NAV LINKS === */
.topbar-link { font-size: 0.875rem; color: var(--fg-muted); text-decoration: none; padding: 0.3rem 0.6rem; border-radius: 5px; }
.topbar-link:hover { color: var(--fg); background: var(--bg-alt); }

/* === DELETE CONFIRM === */
.delete-btn { background: none; border: none; cursor: pointer; color: var(--fg-faint); font-size: 0.875rem; padding: 0.2rem 0.4rem; border-radius: 4px; }
.delete-btn:hover { color: var(--danger); background: rgba(192,57,43,0.08); }