/* ==========================================================
   SCHEME OF WORK SYSTEM — Design System
   Typeface pairing: Lexend (headings/brand — built for reading
   clarity, fitting for an education product) + Inter (body/data/UI).
   Palette: deep ink + indigo core, with a muted role-accent per
   portal instead of loud color blocks, for a calmer, professional feel.
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink:        #111827;
  --ink-soft:   #1f2937;
  --slate:      #475569;
  --slate-light:#94a3b8;
  --bg:         #f4f6fb;
  --surface:    #ffffff;
  --border:     #e5e9f0;

  --indigo:     #4338ca;
  --indigo-dark:#312e81;
  --emerald:    #059669;
  --amber:      #d97706;
  --violet:     #7c3aed;
  --sky:        #2563eb;
  --red:        #dc2626;

  /* per-portal accent (used sparingly: sidebar rail + tags, not big fills) */
  --accent-admin:   var(--indigo);
  --accent-hod:     var(--emerald);
  --accent-teacher: var(--emerald);
  --accent-student: var(--sky);
  --accent-parent:  var(--violet);

  --radius: 0.6rem;
  --radius-lg: 0.9rem;
  --shadow-sm: 0 1px 2px rgba(17,24,39,0.04), 0 1px 1px rgba(17,24,39,0.03);
  --shadow-md: 0 4px 14px rgba(17,24,39,0.07);
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
}

h1, h2, h3, h4, h5, h6, .brand, .display-font {
  font-family: 'Lexend', 'Inter', sans-serif;
  color: var(--ink);
  letter-spacing: -0.01em;
}

a { text-decoration: none; }

/* ---------------- App shell (sidebar layout) ---------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--ink);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
}

.sidebar-accent-bar {
  height: 4px;
  width: 100%;
}
.portal-admin   .sidebar-accent-bar { background: var(--accent-admin); }
.portal-hod     .sidebar-accent-bar,
.portal-teacher .sidebar-accent-bar { background: var(--accent-hod); }
.portal-student .sidebar-accent-bar { background: var(--accent-student); }
.portal-parent  .sidebar-accent-bar { background: var(--accent-parent); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.25rem 1.35rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .icon-badge {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  color: #fff;
}
.portal-admin .icon-badge   { background: var(--accent-admin); }
.portal-hod .icon-badge,
.portal-teacher .icon-badge { background: var(--accent-hod); }
.portal-student .icon-badge { background: var(--accent-student); }
.portal-parent .icon-badge  { background: var(--accent-parent); }

.sidebar-brand .name {
  font-family: 'Lexend', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  line-height: 1.15;
}
.sidebar-brand .portal-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-light);
}

.sidebar-nav {
  flex: 1;
  padding: 0.9rem 0.75rem;
  overflow-y: auto;
}
.sidebar-nav .nav-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-light);
  padding: 0.6rem 0.75rem 0.35rem;
}
.sidebar-nav a.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-nav a.nav-link i { font-size: 1.02rem; width: 18px; text-align: center; opacity: 0.85; }
.sidebar-nav a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.nav-link.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.portal-admin   .sidebar-nav a.nav-link.active { border-left: 3px solid var(--accent-admin); }
.portal-hod     .sidebar-nav a.nav-link.active,
.portal-teacher .sidebar-nav a.nav-link.active { border-left: 3px solid var(--accent-hod); }
.portal-student .sidebar-nav a.nav-link.active { border-left: 3px solid var(--accent-student); }
.portal-parent  .sidebar-nav a.nav-link.active { border-left: 3px solid var(--accent-parent); }

.sidebar-footer {
  padding: 0.9rem 1rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.sidebar-user .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 0.85rem;
  flex-shrink: 0;
}
.sidebar-user .who { line-height: 1.2; overflow: hidden; }
.sidebar-user .who .u-name { color: #fff; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .u-role { color: var(--slate-light); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

.btn-logout {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.45rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  color: #e2e8f0;
  font-size: 0.82rem;
  font-weight: 500;
}
.btn-logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ---------------- Main content ---------------- */

.main-wrapper {
  margin-left: 264px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}
.breadcrumb-trail {
  font-size: 0.82rem;
  color: var(--slate);
  margin: 0;
}
.breadcrumb-trail .current { color: var(--ink); font-weight: 600; }

.content-area {
  padding: 1.75rem;
  flex: 1;
}

/* ---------------- Components ---------------- */

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

.stat-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--indigo);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-card p { margin: 0 0 0.2rem; color: var(--slate); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card h3 { margin: 0; font-size: 1.8rem; font-weight: 700; color: var(--ink); }
.stat-card.c-indigo  { border-left-color: var(--indigo); }
.stat-card.c-emerald { border-left-color: var(--emerald); }
.stat-card.c-amber   { border-left-color: var(--amber); }
.stat-card.c-violet  { border-left-color: var(--violet); }
.stat-card.c-sky     { border-left-color: var(--sky); }

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.page-heading h4 { margin: 0 0 0.2rem; font-weight: 600; }
.page-heading .sub { color: var(--slate); font-size: 0.88rem; margin: 0; }

.btn {
  font-weight: 500;
  border-radius: 8px;
  font-size: 0.88rem;
}
.btn-primary { background: var(--indigo); border-color: var(--indigo); }
.btn-primary:hover { background: var(--indigo-dark); border-color: var(--indigo-dark); }
.btn-success { background: var(--emerald); border-color: var(--emerald); }
.btn-outline-primary { color: var(--indigo); border-color: var(--indigo); }
.btn-outline-primary:hover { background: var(--indigo); border-color: var(--indigo); }

.table { font-size: 0.89rem; }
.table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate);
  border-bottom-width: 1px;
  font-weight: 600;
}
.table td { vertical-align: middle; color: var(--ink-soft); }

.badge { font-weight: 500; font-size: 0.72rem; padding: 0.4em 0.65em; border-radius: 6px; }
.badge-draft     { background-color: #6b7280; }
.badge-submitted { background-color: var(--amber); }
.badge-approved  { background-color: var(--emerald); }
.badge-rejected  { background-color: var(--red); }

.form-label { font-size: 0.85rem; font-weight: 500; color: var(--ink-soft); }
.form-control, .form-select {
  border-color: var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(67,56,202,0.12);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--slate);
}
.empty-state i { font-size: 2rem; color: var(--slate-light); display: block; margin-bottom: 0.6rem; }

/* Read-only rendering of saved rich text content */
.rich-content { font-size: 0.9rem; color: var(--ink-soft); }
.rich-content p { margin-bottom: 0.5rem; }
.rich-content ul, .rich-content ol { margin-bottom: 0.5rem; padding-left: 1.25rem; }
.rich-content img { max-width: 100%; height: auto; border-radius: 6px; }

/* Rendered rich-text content (the Presentation field, saved as HTML) */
.rich-content {
  line-height: 1.7;
  color: var(--ink-soft);
}
.rich-content p { margin-bottom: 0.75rem; }
.rich-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 0.5rem 0; display: block; }
.rich-content ul, .rich-content ol { padding-left: 1.4rem; margin-bottom: 0.75rem; }
.rich-content table { width: 100%; border-collapse: collapse; margin-bottom: 0.75rem; }
.rich-content td, .rich-content th { border: 1px solid var(--border); padding: 0.45rem 0.65rem; }
.rich-content blockquote { border-left: 3px solid var(--indigo); padding-left: 0.9rem; color: var(--slate); margin: 0.75rem 0; }
.rich-content h1, .rich-content h2, .rich-content h3, .rich-content h4 { margin: 0.75rem 0 0.4rem; }

/* term rail: small signature element showing week progress, used on dashboards */
.term-rail { display: flex; align-items: center; gap: 3px; margin-top: 0.4rem; }
.term-rail span {
  height: 5px; flex: 1; border-radius: 3px; background: rgba(255,255,255,0.12);
}
.term-rail span.filled { background: var(--slate-light); }

footer.app-footer {
  text-align: center;
  color: var(--slate-light);
  font-size: 0.8rem;
  padding: 1.5rem;
}

/* ---------------- Login page ---------------- */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  background-image: radial-gradient(circle at 20% 20%, rgba(67,56,202,0.35), transparent 40%),
                     radial-gradient(circle at 80% 80%, rgba(5,150,105,0.25), transparent 40%);
  padding: 1rem;
}
.login-card {
  max-width: 400px;
  width: 100%;
  padding: 2.25rem 2rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.login-brand .icon-badge {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--indigo); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .content-area { padding: 1.1rem; }
}

.mobile-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 36px; height: 36px;
}
@media (max-width: 900px) {
  .mobile-toggle { display: inline-flex; align-items: center; justify-content: center; }
}
