/* ==========================================================================
   School Markaz — Design System v3 (professional SaaS theme)
   Brand: royal blue -> emerald gradient + gold accent (from the SM logo).
   Vanilla CSS: variables, cards, tables, forms, sidebar, mobile nav, print.
   ========================================================================== */
:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --text: #0b1526;
  --muted: #5b6b82;
  --border: #dde5ee;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8effc;
  --accent: #d97706;
  --gold: #f5b301;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --grad: linear-gradient(120deg, #2563eb 0%, #0ea5a4 100%);
  --grad-hero: linear-gradient(130deg, #0b2a6b 0%, #2563eb 45%, #059669 110%);
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(11, 21, 38, .05), 0 10px 30px -12px rgba(11, 21, 38, .18);
  --shadow-lg: 0 24px 60px -18px rgba(11, 21, 38, .35);
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: #bfdbfe; }

/* --- App shell ----------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0a1730 0%, #0d2149 58%, #0a2e2a 130%);
  color: #dbe6f5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 40;
  box-shadow: 6px 0 30px -18px rgba(11, 21, 38, .5);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 16px 18px; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  object-fit: cover; background: #fff; padding: 2px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.brand-text strong { display: block; font-size: 15px; line-height: 1.25; color: #fff; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: #9db4d4; }
.nav { flex: 1; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: #c3d3ea; font-size: 14px;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); text-decoration: none; color: #fff; transform: translateX(2px); }
.nav-link.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 8px 18px -8px rgba(37, 99, 235, .7); }
.nav-icon { width: 22px; text-align: center; }
.sidebar-foot { padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, .09); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
}
.page-title { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.2px; }
.hamburger { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; font-size: 18px; padding: 6px 10px; cursor: pointer; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; font-size: 14px; }
.content { padding: 22px; max-width: 1220px; width: 100%; margin: 0 auto; flex: 1; }

/* --- Cards, grids, stats -------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.card-body { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 18px 16px;
}
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--primary); }
.stat .stat-num { font-size: 31px; font-weight: 800; letter-spacing: -.5px; }
.stat .stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat.primary .stat-num { color: var(--primary); }
.stat.green::before { background: var(--success); } .stat.green .stat-num { color: var(--success); }
.stat.amber::before { background: var(--warning); } .stat.amber .stat-num { color: var(--warning); }
.stat.red::before { background: var(--danger); } .stat.red .stat-num { color: var(--danger); }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th, table.table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.table th { background: var(--surface-muted); font-weight: 600; white-space: nowrap; color: #33475e; }
table.table tr:hover td { background: #f2f7ff; }

/* --- Badges, alerts, buttons ---------------------------------------------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e2e8f0; color: #334155; }
.badge.green { background: #d1fae5; color: #065f46; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.purple { background: #ede9fe; color: #5b21b6; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.btn {
  display: inline-block; padding: 10px 20px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; background: var(--grad); color: #fff;
  box-shadow: 0 8px 18px -8px rgba(37, 99, 235, .55);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover { text-decoration: none; color: #fff; transform: translateY(-1px); filter: brightness(1.06); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-muted); color: var(--text); filter: none; }
.btn.danger { background: var(--danger); box-shadow: 0 8px 18px -8px rgba(220, 38, 38, .55); }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--success); box-shadow: 0 8px 18px -8px rgba(5, 150, 105, .55); }
.btn.small { padding: 6px 13px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Forms ----------------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field input[type="text"], .field input[type="password"], .field input[type="date"],
.field input[type="time"], .field input[type="number"], .field input[type="tel"],
.field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-s);
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }

/* --- Login page ------------------------------------------------------------ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--grad-hero); position: relative; overflow: hidden; }
.login-wrap::before, .login-wrap::after { content: ""; position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.login-wrap::before { width: 420px; height: 420px; background: #0ea5a4; top: -140px; right: -80px; }
.login-wrap::after { width: 380px; height: 380px; background: #f5b301; bottom: -160px; left: -100px; opacity: .28; }
.login-card { position: relative; z-index: 1; background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); padding: 38px; width: 100%; max-width: 400px; }
.login-card h1 { font-size: 21px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

/* --- Modal ------------------------------------------------------------------ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11, 21, 38, .58); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 16px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }

/* --- Shift slip -------------------------------------------------------------- */
.slip { max-width: 420px; margin: 0 auto; background: #fff; border: 2px solid var(--text); border-radius: 4px; padding: 20px; }
.slip h2 { text-align: center; margin: 0 0 4px; font-size: 18px; }
.slip .slip-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.slip table { width: 100%; border-collapse: collapse; }
.slip th, .slip td { border: 1px solid var(--text); padding: 8px; text-align: center; }
.slip .total-row td { font-weight: 800; font-size: 17px; }

/* --- Mobile bottom nav -------------------------------------------------------- */
.bottom-nav { display: none; }

/* --- Responsive --------------------------------------------------------------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease; }
  body.nav-open .sidebar { transform: translateX(0); }
  .hamburger { display: block; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2, .form-row { grid-template-columns: 1fr; }
  .content { padding: 14px 14px 84px; }
  .user-name { display: none; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: #0a1730; border-top: 1px solid rgba(255, 255, 255, .1);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #c3d3ea; font-size: 10px; padding: 4px 2px; }
  .bottom-link:hover { text-decoration: none; color: #fff; }
}

/* --- Print: clean shift slip ---------------------------------------------------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .alert, .no-print { display: none !important; }
  .main { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; margin: 0; }
  .card-head, .card-body .no-print { display: none !important; }
  body { background: #fff; }
}

/* ================= Dark mode, notifications, QR, payroll ================= */
[data-theme="dark"] {
  --bg: #0b1526;
  --surface: #16233c;
  --surface-muted: #101c31;
  --text: #e6eefb;
  --muted: #94a9c7;
  --border: #2b3d5c;
  --primary: #4f83f8;
  --primary-dark: #3b74f2;
  --primary-soft: #1d2f52;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -12px rgba(0, 0, 0, .5);
}
[data-theme="dark"] .badge { background: #334155; color: #e2e8f0; }
[data-theme="dark"] .badge.green { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .badge.amber { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge.red { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .badge.blue { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .badge.purple { background: #4c1d95; color: #ddd6fe; }
[data-theme="dark"] .alert-success { background: #064e3b; color: #a7f3d0; border-color: #065f46; }
[data-theme="dark"] .alert-error { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
[data-theme="dark"] .alert-info { background: #1e3a8a; color: #bfdbfe; border-color: #1e40af; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: #0b1526; color: #e6eefb; border-color: #2b3d5c;
}
[data-theme="dark"] .table th { background: #101c31; color: #b8c9e2; }
[data-theme="dark"] .table tr:hover td { background: #182a49; }
[data-theme="dark"] img.qr-code { background: #fff; padding: 8px; border-radius: 8px; }

/* Theme toggle + notification bell in topbar */
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-muted); }
.notif-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.user-chip { display: flex; align-items: center; gap: 8px; }

/* Notification list */
.notif-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: var(--surface-muted); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-radius: 8px; }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.notif-item.read .notif-dot { background: var(--border); }

/* QR punch */
.qr-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
#qr-reader { width: 100%; max-width: 480px; }
#qr-reader video { border-radius: 12px; }

/* Charts */
.chart-box { position: relative; height: 280px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* Payslip print */
.payslip { max-width: 640px; margin: 0 auto; }
.payslip table { width: 100%; }
@media print {
  .no-print, .sidebar, .topbar, .bottom-nav { display: none !important; }
  .main, .content { margin: 0; padding: 0; }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  body { background: #fff; }
}

/* Mobile polish */
@media (max-width: 640px) {
  .btn { padding: 12px 20px; font-size: 15px; }
  .btn.small { padding: 9px 14px; font-size: 14px; }
  .icon-btn { width: 44px; height: 44px; }
  .card-body { padding: 14px; }
  .user-chip .user-name { display: none; }
  .chart-box { height: 240px; }
  input, select, textarea { font-size: 16px; } /* prevent iOS zoom */
}

/* ================= v4 professional polish ================= */
body { font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3, .page-title, .brand-text strong, .stat .stat-num, .section-title, .price .pamount, .login-card h1 {
  font-family: "Plus Jakarta Sans", "Inter", "Segoe UI", sans-serif;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 3px; }
.nav-group {
  margin: 14px 10px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: 1.6px;
  text-transform: uppercase; color: #7d94b8;
}
.nav-group:first-child { margin-top: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px -3px rgba(37, 99, 235, .6);
}
.stat::after {
  position: absolute; top: 12px; right: 14px; font-size: 25px; opacity: .16; line-height: 1;
}
.stat::after { content: "📊"; }
.stat.primary::after { content: "🎓"; }
.stat.green::after { content: "👩‍🏫"; }
.stat.amber::after { content: "💰"; }
.stat.red::after { content: "⚠️"; }
.welcome {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--grad-hero); color: #fff; border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.welcome::after { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(245, 179, 1, .25); filter: blur(50px); top: -120px; right: 60px; }
.welcome-text h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.4px; }
.welcome-text p { margin: 0; opacity: .88; font-size: 14px; }
.welcome-actions { display: flex; gap: 9px; flex-wrap: wrap; position: relative; z-index: 1; }
.welcome .btn.white { background: #fff; color: #1d4ed8; box-shadow: 0 10px 22px -10px rgba(0, 0, 0, .5); }
.welcome .btn.white:hover { color: #1d4ed8; }
.welcome .btn.ghost { background: rgba(255, 255, 255, .13); color: #fff; border: 1px solid rgba(255, 255, 255, .4); box-shadow: none; }
.welcome .btn.ghost:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.card { transition: box-shadow .2s ease, transform .2s ease; }
.lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* ================= v5 mobile polish ================= */
html, body { overflow-x: clip; }
.page-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .stat-num { font-size: clamp(21px, 6.4vw, 31px); overflow-wrap: anywhere; }
img, video, canvas { max-width: 100%; height: auto; }
@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .user-chip .badge { display: none; }
  .welcome { padding: 18px 16px; }
  .welcome-actions { width: 100%; }
  .welcome-actions .btn { flex: 1 1 30%; justify-content: center; }
  .card-head { padding: 13px 16px; }
  .stat { padding: 14px; }
  .grid-4 { gap: 10px; }
}
