/* ============================================================
   Cyber হাট School Management — Design System
   Concept: the Bangladeshi ruled exercise book (খাতা) — a red
   margin rule, ledger-style tables, roll-register typography.
   Grounded in "হাট" (village marketplace) as a warm communal hub,
   digitized: ink-indigo + register-red + marigold on slate paper.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Tiro+Bangla:ital@0;1&family=Hind+Siliguri:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* ---- color tokens ---- */
  --ink-indigo: #1f2a4a;
  --ink-indigo-dark: #141b33;
  --register-red: #b23a2e;
  --marigold: #e8a93b;
  --marigold-dark: #c8891f;
  --slate-paper: #eff1ec;
  --card-white: #fffdf8;
  --deep-ink: #1b2430;
  --ink-muted: #5b6472;
  --success-green: #3f7d53;
  --success-bg: #e6f2ea;
  --danger-bg: #fbe9e7;
  --border-hairline: #d8dbd2;

  /* ---- type tokens ---- */
  --font-display: 'Tiro Bangla', 'Noto Serif Bengali', serif;
  --font-body: 'Hind Siliguri', 'Noto Sans Bengali', sans-serif;
  --font-data: 'JetBrains Mono', ui-monospace, monospace;

  /* ---- layout tokens ---- */
  --sidebar-w: 240px;
  --radius: 6px;
  --shadow-card: 0 1px 2px rgba(31, 42, 74, 0.06), 0 1px 12px rgba(31, 42, 74, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--slate-paper);
  color: var(--deep-ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink-indigo);
  margin: 0 0 0.4em;
}

h1 {
  font-size: 1.7rem;
}
h2 {
  font-size: 1.25rem;
}
h3 {
  font-size: 1.05rem;
}

a {
  color: var(--ink-indigo);
}

button {
  font-family: var(--font-body);
}

:focus-visible {
  outline: 2px solid var(--marigold-dark);
  outline-offset: 2px;
}

/* ---------------- utility ---------------- */

.numeric {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--ink-muted);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border: none;
  border-radius: var(--radius);
  padding: 0.6em 1.2em;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active {
  transform: translateY(1px);
}

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

.btn-accent {
  background: var(--marigold);
  color: var(--ink-indigo-dark);
}
.btn-accent:hover {
  background: var(--marigold-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-indigo);
  border: 1px solid var(--border-hairline);
}
.btn-ghost:hover {
  background: rgba(31, 42, 74, 0.05);
}

.btn-danger {
  background: var(--register-red);
  color: #fff;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.35em 0.8em;
  font-size: 0.85rem;
}

/* ---------------- form fields ---------------- */

.field {
  margin-bottom: 1.1em;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-indigo);
  margin-bottom: 0.35em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.6em 0.75em;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  background: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--deep-ink);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ink-indigo);
}
.field-error {
  color: var(--register-red);
  font-size: 0.82rem;
  margin-top: 0.3em;
}

/* ---------------- the signature: ruled "খাতা" card ---------------- */
/* A card with the red exercise-book margin rule down the left edge. */

.ledger-card {
  background: var(--card-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.4em 1.4em 1.4em 1.9em;
  position: relative;
  margin-bottom: 1.3em;
}
.ledger-card::before {
  content: '';
  position: absolute;
  top: 0.9em;
  bottom: 0.9em;
  left: 0.85em;
  width: 2px;
  background: var(--register-red);
  opacity: 0.55;
}

.ledger-card h2,
.ledger-card h3 {
  margin-bottom: 0.6em;
}

/* ---------------- ledger-style tables ---------------- */

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.ledger-table th {
  text-align: left;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--ink-indigo);
  padding: 0.5em 0.7em;
}
.ledger-table td {
  padding: 0.55em 0.7em;
  border-bottom: 1px solid var(--border-hairline);
}
.ledger-table tbody tr:nth-child(even) {
  background: rgba(31, 42, 74, 0.025);
}
.ledger-table td.numeric,
.ledger-table th.numeric {
  text-align: right;
}

/* ---------------- badges (grades, status) ---------------- */

.badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-data);
}
.badge-pass {
  background: var(--success-bg);
  color: var(--success-green);
}
.badge-fail {
  background: var(--danger-bg);
  color: var(--register-red);
}
.badge-neutral {
  background: rgba(31, 42, 74, 0.08);
  color: var(--ink-indigo);
}
.badge-gold {
  background: #fbf0da;
  color: var(--marigold-dark);
}

/* ---------------- app shell ---------------- */

#app {
  min-height: 100vh;
}

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink-indigo);
  color: #f2f0e8;
  display: flex;
  flex-direction: column;
  position: relative;
}
.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 3px;
  background: var(--register-red);
  opacity: 0.65;
}

.brand {
  padding: 1.4em 1.2em 1.1em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 0.7em;
}
.brand .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
}
.brand .brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: #fff;
  line-height: 1.25;
}
.brand .brand-name em {
  font-style: normal;
  color: var(--marigold);
}
.brand .brand-sub {
  font-size: 0.68rem;
  color: rgba(242, 240, 232, 0.65);
  margin-top: 0.25em;
  letter-spacing: 0.03em;
}

.nav {
  flex: 1;
  padding: 1em 0.7em;
}
.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(242, 240, 232, 0.42);
  padding: 0.9em 0.8em 0.3em;
}
.nav-section-label:first-child {
  padding-top: 0.2em;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 0.8em;
  border-radius: var(--radius);
  color: rgba(242, 240, 232, 0.82);
  text-decoration: none;
  font-size: 0.92rem;
  margin-bottom: 0.15em;
  cursor: pointer;
}
.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav a.active {
  background: rgba(232, 169, 59, 0.16);
  color: var(--marigold);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1em 1.2em 1.3em;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.82rem;
}
.sidebar-footer .who {
  color: #fff;
  font-weight: 600;
  margin-bottom: 0.6em;
}
.sidebar-footer .role-tag {
  display: inline-block;
  font-size: 0.7rem;
  color: rgba(242, 240, 232, 0.6);
  margin-top: 0.15em;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6em;
  padding: 1em 1.6em;
  background: var(--card-white);
  border-bottom: 1px solid var(--border-hairline);
}

.content {
  padding: 1.6em;
  flex: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.3em;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.3em;
}

@media (max-width: 860px) {
  .shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
  }
  .sidebar::after {
    display: none;
  }
  .nav {
    display: flex;
    overflow-x: auto;
    padding: 0.5em;
  }
  .nav-section-label {
    display: none;
  }
  .nav a {
    white-space: nowrap;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .ledger-card {
    /* চওড়া টেবিল (৫+ কলাম) সরু স্ক্রিনে পুরো পেজ ভেঙে না ফেলে, বরং
       কার্ডের ভেতরেই সাইডওয়ে স্ক্রল করে — কোনো টেবিল/পেজ আলাদাভাবে
       ঠিক করার দরকার নেই, যেহেতু প্রায় প্রতিটা টেবিলই একটা ledger-card
       এর ভেতরে থাকে। */
    overflow-x: auto;
  }
  .content {
    padding: 1em;
  }
  .topbar {
    padding: 0.8em 1em;
  }
}

/* ---------------- stat tiles ---------------- */

.stat-tile {
  background: var(--card-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.1em 1.3em;
}
.stat-tile .stat-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35em;
}
.stat-tile .stat-value {
  font-family: var(--font-data);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--ink-indigo);
}
.stat-tile .stat-value.accent {
  color: var(--marigold-dark);
}

/* ---------------- login screen ---------------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-paper);
  padding: 1.5em;
}

.login-screen::before {
  content: '';
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2.2em 2em 2em 2.4em;
  position: relative;
  animation: card-in 0.4s ease both;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 1.2em;
  bottom: 1.2em;
  left: 1.1em;
  width: 2px;
  background: var(--register-red);
  opacity: 0.55;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-card {
    animation: none;
  }
}

.login-brand {
  text-align: center;
  margin-bottom: 1.6em;
}
.login-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--ink-indigo);
}
.login-brand .brand-name em {
  font-style: normal;
  color: var(--marigold-dark);
}
.login-brand .brand-sub {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 0.3em;
}

.login-error {
  background: var(--danger-bg);
  color: var(--register-red);
  border-radius: var(--radius);
  padding: 0.7em 0.9em;
  font-size: 0.85rem;
  margin-bottom: 1em;
}

/* ---------------- alert / notice banners ---------------- */

.banner {
  border-radius: var(--radius);
  padding: 0.85em 1.1em;
  font-size: 0.88rem;
  margin-bottom: 1.3em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}
.banner-warn {
  background: #fdf3e3;
  color: var(--marigold-dark);
  border: 1px solid #f0d9a8;
}

.empty-state {
  text-align: center;
  padding: 2.5em 1em;
  color: var(--ink-muted);
}

.spinner-line {
  color: var(--ink-muted);
  font-size: 0.88rem;
  padding: 1em 0;
}

.notice-item {
  padding: 0.9em 0;
  border-bottom: 1px solid var(--border-hairline);
}
.notice-item:last-child {
  border-bottom: none;
}
.notice-item .notice-title {
  font-weight: 600;
  color: var(--ink-indigo);
  margin-bottom: 0.2em;
}
.notice-item .notice-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 0.3em;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.plain-list li {
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border-hairline);
}
.plain-list li:last-child {
  border-bottom: none;
}

/* ---- student photo / avatar ---- */
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-hairline);
  background: var(--bg-panel, #f2f2f2);
}
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-hairline);
  background: var(--bg-panel, #f2f2f2);
  vertical-align: middle;
}
.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-size: 0.7rem;
}
