/* ─── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --font-sans: 'Plus Jakarta Sans', sans-serif;

    /* Colors */
    --color-primary:    #1d4ed8;
    --color-primary-h:  #1e40af;
    --color-bg:         #f1f5f9;
    --color-surface:    #ffffff;
    --color-border:     #e2e8f0;
    --color-text:       #0f172a;
    --color-text-muted: #64748b;
    --color-sidebar-bg: #0f172a;
    --color-sidebar-fg: #94a3b8;
    --color-sidebar-active: #1d4ed8;

    --color-green:  #16a34a;
    --color-yellow: #d97706;
    --color-red:    #dc2626;
    --color-blue:   #2563eb;
    --color-purple: #7c3aed;

    /* Spacing */
    --sidebar-w: 260px;
    --topbar-h:  60px;
    --radius:    10px;
    --radius-sm: 6px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

html, body { height: 100%; }
body { font-family: var(--font-sans); font-size: 14px; background: var(--color-bg);
       color: var(--color-text); line-height: 1.6; }

/* ─── Layout ─────────────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w); background: var(--color-sidebar-bg);
    display: flex; flex-direction: column; z-index: 100;
    overflow-y: auto;
}

.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 24px 28px;
    margin-top: var(--topbar-h);
}

/* ─── Sidebar ────────────────────────────────────────────────────── */
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon { width: 36px; height: 36px; flex-shrink: 0; }
.brand-name { display: block; font-size: 15px; font-weight: 700; color: #f1f5f9; }
.brand-sub  { display: block; font-size: 11px; color: #475569; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--color-primary);
    color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center;
    flex-shrink: 0;
}
.user-name { display: block; font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { display: block; font-size: 11px; color: #64748b; }

.nav-list { list-style: none; padding: 12px 12px 0; flex: 1; }
.nav-item  { margin-bottom: 2px; }
.nav-link  {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--color-sidebar-fg); text-decoration: none; font-size: 13.5px;
    font-weight: 500; position: relative; transition: all .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-link.active { background: rgba(29,78,216,.2); color: #93c5fd; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-active-bar {
    position: absolute; right: 0; top: 6px; bottom: 6px;
    width: 3px; background: var(--color-primary); border-radius: 2px;
}

.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,.06); }
.logout-btn {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
    background: none; border: none; cursor: pointer;
    color: #64748b; font-size: 13px; font-family: var(--font-sans);
    transition: all .15s;
}
.logout-btn svg { width: 15px; height: 15px; }
.logout-btn:hover { background: rgba(220,38,38,.15); color: #fca5a5; }

/* ─── Topbar ─────────────────────────────────────────────────────── */
.topbar {
    position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h);
    background: var(--color-surface); border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; padding: 0 28px; z-index: 99;
    box-shadow: var(--shadow);
}
.topbar-breadcrumb { font-size: 13px; color: var(--color-text-muted); }
.topbar-breadcrumb strong { color: var(--color-text); }

/* ─── Page header ────────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 24px;
}
.page-title    { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.page-subtitle { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
.page-actions  { display: flex; gap: 8px; }

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--color-surface); border-radius: var(--radius);
    border: 1px solid var(--color-border); box-shadow: var(--shadow);
}
.card__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--color-border);
}
.card__header h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ─── Stat Cards ─────────────────────────────────────────────────── */
.stats-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--color-surface); border-radius: var(--radius);
    border: 1px solid var(--color-border); padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-card__body { display: flex; justify-content: space-between; align-items: baseline; }
.stat-card__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-card__value { font-size: 28px; font-weight: 700; }
.stat-card__footer { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.stat-card__pct { font-size: 11px; color: var(--color-text-muted); }

.stat-card--green  { border-top: 3px solid var(--color-green); }
.stat-card--yellow { border-top: 3px solid var(--color-yellow); }
.stat-card--blue   { border-top: 3px solid var(--color-blue); }
.stat-card--purple { border-top: 3px solid var(--color-purple); }
.stat-card--red    { border-top: 3px solid var(--color-red); }

.stat-card--green  .stat-card__value { color: var(--color-green); }
.stat-card--yellow .stat-card__value { color: var(--color-yellow); }
.stat-card--blue   .stat-card__value { color: var(--color-blue); }
.stat-card--purple .stat-card__value { color: var(--color-purple); }
.stat-card--red    .stat-card__value { color: var(--color-red); }

.progress-bar { flex: 1; height: 4px; background: #e2e8f0; border-radius: 2px; overflow: hidden; }
.progress-bar__fill { height: 100%; background: currentColor; border-radius: 2px; transition: width .4s; }
.stat-card--green  .progress-bar__fill { background: var(--color-green); }
.stat-card--yellow .progress-bar__fill { background: var(--color-yellow); }
.stat-card--blue   .progress-bar__fill { background: var(--color-blue); }
.stat-card--purple .progress-bar__fill { background: var(--color-purple); }
.stat-card--red    .progress-bar__fill { background: var(--color-red); }

/* ─── Filter Bar ─────────────────────────────────────────────────── */
.filter-bar  { background: var(--color-surface); border: 1px solid var(--color-border);
               border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.filter-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 600; text-transform: uppercase;
                      letter-spacing: .05em; color: var(--color-text-muted); }

/* ─── Forms ──────────────────────────────────────────────────────── */
.form-control {
    height: 36px; padding: 0 10px; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-sans);
    background: #fff; color: var(--color-text); transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--color-primary);
                      box-shadow: 0 0 0 3px rgba(29,78,216,.1); }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px;
    font-weight: 600; font-family: var(--font-sans); border: none;
    cursor: pointer; text-decoration: none; transition: all .15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-h); }
.btn-outline { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-outline:hover { background: var(--color-bg); }
.btn-ghost   { background: transparent; color: var(--color-text-muted); border: none; }
.btn-ghost:hover { background: var(--color-bg); }
.btn-xs { padding: 4px 8px; font-size: 12px; }

/* ─── Tables ─────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    padding: 10px 16px; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--color-text-muted);
    background: #f8fafc; border-bottom: 1px solid var(--color-border); text-align: left;
}
.table td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table--hover tbody tr:hover { background: #f8fafc; }
.text-center { text-align: center; }
.text-green  { color: var(--color-green); }
.text-yellow { color: var(--color-yellow); }
.text-red    { color: var(--color-red); }
.text-blue   { color: var(--color-blue); }
.text-purple { color: var(--color-purple); }
.text-muted  { color: var(--color-text-muted); }
.py-8 { padding-top: 32px; padding-bottom: 32px; }

/* ─── Student cell ───────────────────────────────────────────────── */
.student-cell { display: flex; align-items: center; gap: 10px; }
.student-avatar {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    flex-shrink: 0;
}
.student-avatar--placeholder {
    background: var(--color-primary); color: #fff;
    display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.student-name { font-weight: 600; font-size: 13.5px; }
.student-nis  { font-size: 11px; color: var(--color-text-muted); }

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; padding: 3px 8px;
    border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.badge-success   { background: #dcfce7; color: #15803d; }
.badge-warning   { background: #fef9c3; color: #b45309; }
.badge-info      { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: #f3e8ff; color: #6d28d9; }
.badge-danger    { background: #fee2e2; color: #b91c1c; }
.badge-muted     { background: #f1f5f9; color: #64748b; }
.badge-outline   { background: transparent; border: 1px solid var(--color-border); color: var(--color-text-muted); }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #b45309; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #f3e8ff; color: #6d28d9; }
.badge-red    { background: #fee2e2; color: #b91c1c; }

/* ─── Alerts ─────────────────────────────────────────────────────── */
.alert { display: flex; align-items: center; gap: 10px;
         padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; fill: currentColor; }
.alert-success { background: #dcfce7; color: #15803d; }
.alert-danger  { background: #fee2e2; color: #b91c1c; }

/* ─── Dropdown ───────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 4px);
    background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); min-width: 120px; z-index: 200;
}
.dropdown:hover .dropdown-menu,
.dropdown.open   .dropdown-menu { display: block; }
.dropdown-item {
    display: block; width: 100%; padding: 8px 14px; font-size: 13px;
    background: none; border: none; text-align: left; cursor: pointer;
    font-family: var(--font-sans); color: var(--color-text);
    transition: background .1s;
}
.dropdown-item:hover  { background: var(--color-bg); }
.dropdown-item.active { background: #dbeafe; color: var(--color-blue); font-weight: 600; }

/* ─── Pagination ─────────────────────────────────────────────────── */
.pagination {
    display: flex; gap: 4px; padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}
.page-link {
    display: grid; place-items: center; width: 32px; height: 32px;
    border-radius: var(--radius-sm); font-size: 13px; text-decoration: none;
    color: var(--color-text); border: 1px solid var(--color-border); transition: all .15s;
}
.page-link:hover  { background: var(--color-bg); }
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ─── Pulse dot ──────────────────────────────────────────────────── */
.pulse-dot {
    display: inline-block; width: 8px; height: 8px; background: #22c55e;
    border-radius: 50%; flex-shrink: 0;
    animation: pulse 1.8s ease infinite;
}
.pulse-dot--lg { width: 12px; height: 12px; }
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(1.3); }
}

/* ─── Live Feed ──────────────────────────────────────────────────── */
.live-grid {
    display: grid; grid-template-columns: 1fr 220px; gap: 16px; align-items: start;
}
.live-feed-card { overflow: hidden; }
.live-feed { max-height: calc(100vh - 260px); overflow-y: auto; }
.live-feed__empty { padding: 40px; text-align: center; color: var(--color-text-muted); font-size: 13px; }

.feed-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; border-bottom: 1px solid #f1f5f9;
    transition: background .3s;
}
.feed-item--new { background: #eff6ff; animation: slideIn .4s ease; }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}
.feed-item__time   { font-size: 12px; font-weight: 700; color: var(--color-text-muted); width: 40px; }
.feed-item__avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--color-primary);
    color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0;
}
.feed-item__info   { flex: 1; min-width: 0; }
.feed-item__name   { font-weight: 600; font-size: 13.5px; }
.feed-item__meta   { font-size: 12px; color: var(--color-text-muted); }
.feed-item__badge  { flex-shrink: 0; }

.live-stats-panel { display: flex; flex-direction: column; gap: 10px; }
.live-stat-card { padding: 16px 20px; text-align: center; }
.live-stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase;
                   letter-spacing: .06em; color: var(--color-text-muted); }
.live-stat-value { font-size: 36px; font-weight: 700; margin-top: 4px; }
.live-stat-card--green  .live-stat-value { color: var(--color-green); }
.live-stat-card--yellow .live-stat-value { color: var(--color-yellow); }
.live-stat-card--red    .live-stat-value { color: var(--color-red); }
.live-stat-card--blue   .live-stat-value { color: var(--color-blue); }

/* ─── Auth page ──────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.auth-card {
    background: #fff; border-radius: 14px; padding: 40px 36px;
    width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-logo  { text-align: center; margin-bottom: 28px; }
.auth-logo svg { width: 52px; height: 52px; }
.auth-title { font-size: 22px; font-weight: 700; text-align: center; }
.auth-sub   { text-align: center; color: var(--color-text-muted); font-size: 13px; margin-bottom: 28px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 700;
              text-transform: uppercase; letter-spacing: .05em;
              color: var(--color-text-muted); margin-bottom: 5px; }
.form-control-full { width: 100%; height: 42px; }
.btn-full { width: 100%; justify-content: center; height: 42px; font-size: 14px; }
.form-error { font-size: 12px; color: var(--color-red); margin-top: 4px; }
.alert-form { padding: 10px 14px; font-size: 13px; border-radius: var(--radius-sm);
              background: #fee2e2; color: #b91c1c; margin-bottom: 16px; }
