/* ============================================================
   SchoolComms Admin Portal — stylesheet
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f5fb;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .05);
  --sidebar-w: 248px;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s;
  background: var(--line); color: var(--ink);
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--muted); padding: 6px; border-radius: 8px; position: relative; line-height: 1;
}
.icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 60%, #1e40af 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 24px; margin-top: 10px; }
.login-brand p { color: var(--muted); font-size: 13.5px; }
.logo-badge {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; letter-spacing: 1px;
}
.logo-badge.small { width: 34px; height: 34px; font-size: 14px; border-radius: 9px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #374151; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14.5px;
}
.login-card input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.login-card .btn { margin-top: 20px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login-hint { color: var(--muted); font-size: 12px; margin-top: 14px; text-align: center; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #111827; color: #d1d5db; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08); color: #fff; font-weight: 700; font-size: 16px;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.sidebar-school { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.school-picker {
  width: 100%; padding: 7px 8px; border-radius: 8px; font-size: 13px;
  border: 1px solid rgba(255,255,255,.15); background: #1f2937; color: #e5e7eb;
}
.school-picker:focus { outline: none; border-color: var(--primary); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 0;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: #d1d5db; text-decoration: none;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-ico { width: 20px; text-align: center; }
.nav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; padding: 14px 12px 4px; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta strong { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 12px; color: #9ca3af; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 19px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.notif-badge {
  position: absolute; top: 0; right: 0; background: var(--danger); color: #fff;
  font-size: 10.5px; border-radius: 999px; padding: 1px 5px; font-weight: 700;
}
.content { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------- Cards & stats ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 16px; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  border-top: 3px solid var(--primary); display: flex; flex-direction: column; gap: 4px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--ink); }
.stat-card .stat-label { color: var(--muted); font-size: 13px; }
.stat-card.green { border-top-color: var(--success); }
.stat-card.amber { border-top-color: var(--warning); }
.stat-card.red { border-top-color: var(--danger); }
.stat-card.purple { border-top-color: #7c3aed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
tr:hover td { background: #fafafd; }
.row-actions { display: flex; gap: 6px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.gray { background: #f3f4f6; color: #374151; }
.badge.purple { background: #ede9fe; color: #5b21b6; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary-light); border-color: var(--primary);
}
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Lists ---------- */
.item-list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item .item-body { flex: 1; min-width: 0; }
.item .item-title { font-weight: 600; }
.item .item-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Notifications panel ---------- */
.notif-panel {
  position: fixed; right: 18px; top: 64px; width: 340px; max-height: 70vh; overflow-y: auto;
  background: #fff; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.18);
  z-index: 50; border: 1px solid var(--line);
}
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.notif-list { padding: 4px 0; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; cursor: pointer; }
.notif-item:hover { background: #f9fafb; }
.notif-item.unread { background: var(--primary-light); }
.notif-item .n-title { font-weight: 600; font-size: 13.5px; }
.notif-item .n-time { font-size: 12px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-body { padding: 20px; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: slideIn .2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Misc ---------- */
.empty-state { text-align: center; color: var(--muted); padding: 40px 0; }
.search-row { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.search-row input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; flex: 1; min-width: 200px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; border: none; }
.pill.active { background: var(--primary); color: #fff; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.grow { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
  .topbar h2 { font-size: 16px; }
}
.menu-toggle { display: none; }
@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .notif-panel { width: calc(100vw - 24px); right: 12px; }
}
