/* ──────────────────────────────────────────────────────────────────────────
   School Management System — panel styling.

   Every colour is a CSS variable so a school's brand colour can be swapped in
   one place, and so the right-to-left Urdu layout only has to flip direction
   rather than restate the palette.
   ────────────────────────────────────────────────────────────────────────── */
:root {
    --brand:        #1d4ed8;
    --brand-dark:   #1e3a8a;
    --brand-light:  #3b82f6;
    --brand-wash:   #eff6ff;
    --accent:       #f59e0b;
    --good:         #16a34a;
    --good-wash:    #dcfce7;
    --bad:          #dc2626;
    --bad-wash:     #fee2e2;
    --warn:         #d97706;
    --warn-wash:    #fef9c3;
    --ink:          #0f172a;
    --ink-soft:     #475569;
    --ink-faint:    #94a3b8;
    --line:         #e2e8f0;
    --line-soft:    #f1f5f9;
    --surface:      #ffffff;
    --canvas:       #f1f5f9;
    --sidebar-bg:   #0f172a;
    --sidebar-w:    248px;
    --topbar-h:     60px;
    --radius:       12px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--canvas);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
body[dir="rtl"] { font-family: 'Noto Nastaliq Urdu', 'Inter', 'Segoe UI', sans-serif; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    width: var(--sidebar-w); background: var(--sidebar-bg);
    display: flex; flex-direction: column; z-index: 1000;
    transition: transform .25s;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
    text-decoration: none; flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 40px; height: 40px; border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
    display: grid; place-items: center; color: #fff; font-size: 18px;
    flex-shrink: 0; box-shadow: 0 4px 14px rgba(59,130,246,.42);
}
.sidebar-brand .brand-text { font-weight: 700; font-size: 14px; color: #f1f5f9; line-height: 1.25; }
.sidebar-brand .brand-sub  { font-size: 10.5px; color: #64748b; margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0 16px; scrollbar-width: thin; scrollbar-color: #1e293b transparent; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 9px; }

.nav-section-title {
    font-size: 9.5px; font-weight: 700; letter-spacing: 1.3px;
    color: #475569; text-transform: uppercase; padding: 15px 20px 5px;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px; margin: 1px 10px;
    padding: 9px 12px; color: #94a3b8; text-decoration: none;
    font-size: 13px; font-weight: 500; border-radius: 8px;
    border-inline-start: 3px solid transparent; transition: all .15s;
}
.sidebar-nav a:hover { color: #e2e8f0; background: rgba(255,255,255,.06); }
.sidebar-nav a.active {
    color: #fff; background: rgba(59,130,246,.18);
    border-inline-start-color: var(--brand-light);
}
.sidebar-nav a .nav-icon { width: 18px; text-align: center; font-size: 13.5px; flex-shrink: 0; }
.sidebar-nav a .badge-pill {
    margin-inline-start: auto; background: var(--bad); color: #fff;
    border-radius: 99px; font-size: 10px; padding: 2px 7px; font-weight: 600;
}

.sidebar-footer { padding: 13px 15px; border-top: 1px solid rgba(255,255,255,.07); flex-shrink: 0; }
.user-info-wrap { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { color: #e2e8f0; font-size: 12.5px; font-weight: 600; }
.user-role { color: #64748b; font-size: 10.5px; margin-top: 1px; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
#topbar {
    position: fixed; top: 0; inset-inline-start: var(--sidebar-w); inset-inline-end: 0;
    height: var(--topbar-h); background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; padding: 0 22px; z-index: 999; gap: 10px;
}
#topbar .page-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-btn {
    width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
    background: #f8fafc; border: 1px solid var(--line); color: var(--ink-soft);
    cursor: pointer; text-decoration: none; transition: all .15s; position: relative; flex-shrink: 0;
}
.topbar-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.school-pill {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--brand-wash); color: var(--brand-dark);
    border: 1px solid #bfdbfe; border-radius: 99px; padding: 5px 13px;
    font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.pending-badge {
    position: absolute; top: 5px; inset-inline-end: 5px; width: 8px; height: 8px;
    background: var(--bad); border-radius: 50%; border: 1.5px solid #fff;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
#main-content {
    margin-inline-start: var(--sidebar-w); margin-top: var(--topbar-h);
    padding: 22px 24px 48px; min-height: calc(100vh - var(--topbar-h));
}
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 21px; font-weight: 700; }
.page-header .sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.stat-card, .content-card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(15,23,42,.05), 0 0 0 1px rgba(15,23,42,.04);
}
.stat-card { padding: 18px; transition: box-shadow .2s, transform .2s; }
.stat-card:hover { box-shadow: 0 6px 20px rgba(15,23,42,.09); transform: translateY(-1px); }
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 11px;
    display: grid; place-items: center; font-size: 18px; margin-bottom: 13px;
}
.stat-card .stat-val { font-size: 25px; font-weight: 700; letter-spacing: -.5px; }
.stat-card .stat-lbl { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; font-weight: 500; }
.stat-card .stat-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 8px; }

.content-card { overflow: hidden; }
.card-header-custom {
    padding: 15px 19px; border-bottom: 1px solid var(--line-soft);
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.card-header-custom h5 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body-custom { padding: 19px; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table-custom { width: 100%; border-collapse: collapse; }
.table-custom th {
    font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
    color: var(--ink-faint); padding: 11px 15px; background: #f8fafc;
    border-bottom: 1px solid var(--line-soft); white-space: nowrap; text-align: start;
}
.table-custom td {
    padding: 12px 15px; font-size: 13px; color: #334155;
    border-bottom: 1px solid var(--line-soft); vertical-align: middle;
}
.table-custom tr:last-child td { border-bottom: none; }
.table-custom tbody tr:hover td { background: #fafbff; }
.table-custom .num { text-align: end; font-variant-numeric: tabular-nums; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge-status {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-present, .badge-approved, .badge-paid { background: var(--good-wash); color: var(--good); }
.badge-absent, .badge-declined, .badge-overdue { background: var(--bad-wash); color: var(--bad); }
.badge-late, .badge-pending, .badge-partial { background: var(--warn-wash); color: var(--warn); }
.badge-info { background: var(--brand-wash); color: var(--brand-dark); }
.badge-muted { background: var(--line-soft); color: var(--ink-soft); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-label-sm {
    font-size: 10.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
    color: var(--ink-soft); display: block; margin-bottom: 5px;
}
.form-control, .form-select {
    border-radius: 9px; border: 1.5px solid var(--line);
    font-size: 13.5px; padding: 9px 12px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.14); outline: none;
}
.btn-accent {
    background: linear-gradient(135deg, var(--brand-light), var(--brand));
    color: #fff; border: none; border-radius: 9px; padding: 9px 18px;
    font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .15s;
    display: inline-flex; align-items: center; gap: 7px; justify-content: center;
    font-family: inherit; text-decoration: none; box-shadow: 0 2px 8px rgba(29,78,216,.28);
}
.btn-accent:hover { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; transform: translateY(-1px); }
.btn-outline-soft {
    background: #f8fafc; color: var(--ink-soft); border: 1.5px solid var(--line);
    border-radius: 9px; padding: 8px 16px; font-size: 13px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
    font-family: inherit; font-weight: 500; transition: all .15s;
}
.btn-outline-soft:hover { background: var(--line-soft); border-color: #cbd5e1; color: #334155; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert-soft-success, .alert-soft-danger, .alert-soft-info {
    border-radius: 10px; padding: 12px 15px; font-size: 13.5px;
    display: flex; align-items: center; gap: 9px; margin-bottom: 18px;
}
.alert-soft-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-soft-danger  { background: #fff1f2; border: 1px solid #fecdd3; color: #be123c; }
.alert-soft-info    { background: var(--brand-wash); border: 1px solid #bfdbfe; color: var(--brand-dark); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { padding: 46px 20px; text-align: center; color: var(--ink-faint); }
.empty-state i { font-size: 36px; opacity: .35; display: block; margin-bottom: 12px; }
.empty-state .title { font-size: 14.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.empty-state .hint { font-size: 12.5px; }

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress-bar-custom { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }

/* ── Mini chart (fee collection bars) ────────────────────────────────────── */
.mini-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.mini-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.mini-chart .bar {
    width: 100%; max-width: 34px; border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--brand-light), var(--brand));
    min-height: 3px; transition: height .5s ease;
}
.mini-chart .bar-lbl { font-size: 10.5px; color: var(--ink-faint); font-weight: 500; }

/* ── Attendance register ─────────────────────────────────────────────────── */
.mark-group { display: inline-flex; gap: 3px; }
.mark-btn {
    width: 34px; height: 30px; border-radius: 7px; border: 1.5px solid var(--line);
    background: #fff; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--ink-faint);
    transition: all .12s; font-family: inherit;
}
.mark-btn:hover { border-color: #cbd5e1; }
.mark-btn.on[data-mark="P"] { background: var(--good);  border-color: var(--good);  color: #fff; }
.mark-btn.on[data-mark="A"] { background: var(--bad);   border-color: var(--bad);   color: #fff; }
.mark-btn.on[data-mark="L"] { background: var(--warn);  border-color: var(--warn);  color: #fff; }
.mark-btn.on[data-mark="E"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Bootstrap polish ────────────────────────────────────────────────────── */
.card { border: none; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(15,23,42,.05), 0 0 0 1px rgba(15,23,42,.04); }
.btn { border-radius: 9px; font-weight: 600; font-size: 13.5px; }
.btn-primary { background: linear-gradient(135deg, var(--brand-light), var(--brand)); border: none; }
.btn-primary:hover { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.modal-content { border: none; border-radius: 14px; }
.nav-tabs .nav-link { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); border: none; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    #sidebar { transform: translateX(-100%); }
    body[dir="rtl"] #sidebar { transform: translateX(100%); }
    #sidebar.open { transform: translateX(0); }
    #topbar { inset-inline-start: 0; }
    #main-content { margin-inline-start: 0; padding: 15px; }
    .page-header h1 { font-size: 18px; }
}

/* ── Print (report cards, receipts, payslips) ────────────────────────────── */
@media print {
    #sidebar, #topbar, .no-print { display: none !important; }
    #main-content { margin: 0; padding: 0; }
    body { background: #fff; }
    .content-card { box-shadow: none; border: 1px solid #ddd; }
}
