/**
 * PRIS Lanka Student MIS - Modern Design System 2026
 * Unified Theme: Slate & Royal Blue Enterprise SaaS
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --navbar-bg: #ffffff;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* TOP NAVBAR */
.navbar-modern {
    background: var(--navbar-bg) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    height: 64px;
    padding: 0 1.5rem;
    z-index: 1030;
}

.navbar-brand-modern {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary) !important;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.brand-icon-box {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* SIDEBAR */
.sidebar-modern {
    position: fixed;
    top: 64px;
    left: 0;
    height: calc(100vh - 64px);
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1020;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    border-right: 1px solid #1e293b;
    padding: 1rem 0;
}

.sidebar-modern::-webkit-scrollbar {
    width: 5px;
}
.sidebar-modern::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 10px;
}

.sidebar-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    padding: 0.75rem 1.5rem 0.25rem;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    margin: 2px 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-nav-item i {
    width: 22px;
    font-size: 0.95rem;
    margin-right: 10px;
    color: #64748b;
    transition: var(--transition);
}

.sidebar-nav-item:hover {
    background: var(--sidebar-hover);
    color: #f1f5f9;
}
.sidebar-nav-item:hover i {
    color: #93c5fd;
}

.sidebar-nav-item.active {
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}
.sidebar-nav-item.active i {
    color: #ffffff;
}

/* MAIN CONTENT */
.main-content-modern {
    margin-left: 260px;
    margin-top: 64px;
    padding: 1.75rem 2rem;
    min-height: calc(100vh - 64px);
    transition: var(--transition);
}

@media (max-width: 991.98px) {
    .sidebar-modern {
        left: -260px;
    }
    .sidebar-modern.show {
        left: 0;
    }
    .main-content-modern {
        margin-left: 0;
        padding: 1rem;
    }
}

/* CARDS */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* KPI STATS CARDS */
.kpi-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.kpi-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* BUTTONS */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* TABLES */
.table {
    margin-bottom: 0;
    vertical-align: middle;
}
.table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}
.table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.table-hover tbody tr:hover {
    background-color: #f1f5f9;
}

/* FORM CONTROLS */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* BADGES */
.badge {
    font-weight: 600;
    border-radius: 6px;
    padding: 0.35em 0.65em;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* CODE / MONO */
code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ==================================================================
   v3 additions: dark mode, command palette, utilities
   ================================================================== */
body { background-color: var(--bg-main); }
.app-footer { background: var(--card-bg); }
.branch-pill { background: var(--bg-main); color: var(--text-primary); }
.kpi-card { background: var(--card-bg); }
:focus-visible { outline: 3px solid rgba(59,130,246,.55); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

[data-bs-theme="dark"] {
    --navbar-bg: #0b1220;
    --bg-main: #0b1120;
    --card-bg: #111827;
    --border-color: #1f2937;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --primary-light: #172554;
    --bs-body-bg: #0b1120;
    --bs-body-color: #e5e7eb;
    --bs-border-color: #1f2937;
    --bs-tertiary-bg: #111827;
    --bs-secondary-bg: #1f2937;
}
[data-bs-theme="dark"] .navbar-brand-modern { color: #f1f5f9 !important; }
[data-bs-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--text-primary); }
[data-bs-theme="dark"] .table thead th { background: #0f172a; color: #94a3b8; }
[data-bs-theme="dark"] .table-hover tbody tr:hover { background-color: #1e293b; }
[data-bs-theme="dark"] .table-light { --bs-table-bg: #0f172a; --bs-table-color: #cbd5e1; }
[data-bs-theme="dark"] .bg-white, [data-bs-theme="dark"] .bg-light { background-color: var(--card-bg) !important; color: var(--text-primary); }
[data-bs-theme="dark"] .text-dark { color: var(--text-primary) !important; }
[data-bs-theme="dark"] .btn-light { --bs-btn-bg: #1f2937; --bs-btn-border-color: #374151; --bs-btn-color: #e5e7eb; --bs-btn-hover-bg: #374151; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background-color: #0f172a; color: var(--text-primary); border-color: #334155; }
[data-bs-theme="dark"] code { background: #1f2937; color: #e5e7eb; }
[data-bs-theme="dark"] .modal-content, [data-bs-theme="dark"] .dropdown-menu { background: var(--card-bg); }

/* Command palette trigger */
.cmdk-trigger {
    flex: 0 1 420px; margin: 0 1rem; align-items: center; gap: .6rem;
    background: var(--bg-main); border: 1px solid var(--border-color); color: var(--text-secondary);
    border-radius: 10px; padding: .4rem .75rem; font-size: .85rem; cursor: pointer; transition: var(--transition);
}
.cmdk-trigger:hover { border-color: #3b82f6; color: var(--text-primary); }
.cmdk-trigger span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd { background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: 5px; padding: 1px 6px; font-size: .72rem; font-family: inherit; box-shadow: 0 1px 0 var(--border-color); }

/* Command palette dialog */
.cmdk { width: min(640px, 94vw); max-height: 70vh; padding: 0; border: 1px solid var(--border-color); border-radius: 14px;
        background: var(--card-bg); color: var(--text-primary); box-shadow: 0 25px 60px -10px rgba(0,0,0,.45); margin-top: 12vh; overflow: hidden; }
.cmdk::backdrop { background: rgba(15,23,42,.55); backdrop-filter: blur(3px); }
.cmdk[open] { display: flex; flex-direction: column; animation: cmdkIn .14s ease-out; }
@keyframes cmdkIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
.cmdk-input-wrap { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--border-color); }
.cmdk-input-wrap input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text-primary); font-size: 1rem; }
.cmdk-list { list-style: none; margin: 0; padding: .4rem; overflow-y: auto; flex: 1; }
.cmdk-group { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: .6rem .7rem .25rem; }
.cmdk-item { display: flex; align-items: center; gap: .75rem; padding: .55rem .7rem; border-radius: 8px; cursor: pointer; }
.cmdk-item i { width: 20px; text-align: center; color: var(--text-muted); }
.cmdk-item.active, .cmdk-item:hover { background: var(--primary); color: #fff; }
.cmdk-item.active i, .cmdk-item:hover i, .cmdk-item.active .cmdk-sub, .cmdk-item:hover .cmdk-sub { color: rgba(255,255,255,.85); }
.cmdk-title { font-weight: 600; font-size: .9rem; }
.cmdk-sub { font-size: .78rem; color: var(--text-secondary); }
.cmdk-empty { padding: 1.5rem; text-align: center; color: var(--text-muted); }
.cmdk-foot { display: flex; gap: 1rem; justify-content: flex-end; padding: .5rem 1rem; border-top: 1px solid var(--border-color); font-size: .75rem; color: var(--text-muted); }

/* Risk badges / analytics */
.risk-high { background: #fee2e2; color: #b91c1c; }
.risk-medium { background: #fef3c7; color: #b45309; }
.risk-low { background: #dcfce7; color: #15803d; }
[data-bs-theme="dark"] .risk-high { background: #450a0a; color: #fca5a5; }
[data-bs-theme="dark"] .risk-medium { background: #451a03; color: #fcd34d; }
[data-bs-theme="dark"] .risk-low { background: #052e16; color: #86efac; }
.score-ring { --v: 0; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
    background: radial-gradient(closest-side, var(--card-bg) 78%, transparent 80% 100%), conic-gradient(var(--ring, #ef4444) calc(var(--v) * 1%), var(--border-color) 0); }

@media print {
    .sidebar-modern, .navbar-modern, .app-footer, .no-print, .cmdk { display: none !important; }
    .main-content-modern { margin: 0 !important; padding: 0 !important; }
}
