:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --accent: #22d3ee;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --bg: #f1f5f9;
    --sidebar-width: 260px;
    --topbar-height: 72px;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
}

/* App shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.main-shell {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    margin-inline-start: var(--sidebar-width);
    transition: margin-inline-start 0.25s ease;
}

body.sidebar-collapsed .main-shell {
    margin-inline-start: 0;
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #1e293b 100%);
    color: #e2e8f0;
    padding: 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}

.btn-sidebar-close {
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    margin-bottom: 0;
    padding: 0.25rem 0.5rem;
    min-width: 0;
}

.brand-logo {
    width: 40px;
    height: 40px;
}

.brand-text {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

    .side-nav .nav-link,
    .side-group summary {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        padding: 0.65rem 0.75rem;
        border-radius: 10px;
        color: #cbd5e1;
        text-decoration: none;
        font-weight: 500;
        font-size: 0.92rem;
        transition: background 0.2s, color 0.2s;
    }

        .side-nav .nav-link:hover,
        .side-group summary:hover {
            background: rgba(255, 255, 255, 0.08);
            color: #fff;
        }

        .side-nav .nav-link.active,
        .sub-nav a.active {
            background: rgba(99, 102, 241, 0.35);
            color: #fff;
        }

.side-group {
    border-radius: 10px;
}

    .side-group summary {
        list-style: none;
        cursor: pointer;
    }

        .side-group summary::-webkit-details-marker {
            display: none;
        }

        .side-group summary::after {
            content: "\F282";
            font-family: bootstrap-icons;
            margin-left: auto;
            font-size: 0.75rem;
            opacity: 0.7;
        }

    .side-group[open] summary::after {
        content: "\F286";
    }

.sub-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.25rem 0 0.5rem 2rem;
}

    .sub-nav a {
        color: #94a3b8;
        text-decoration: none;
        font-size: 0.86rem;
        padding: 0.45rem 0.5rem;
        border-radius: 8px;
    }

        .sub-nav a:hover {
            color: #fff;
            background: rgba(255, 255, 255, 0.06);
        }

    .sub-nav .disabled-link {
        opacity: 0.45;
        pointer-events: none;
    }

.sidebar-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-link {
    color: #fca5a5 !important;
}

/* Topbar */
.topbar {
    min-height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-wrap: wrap;
}

    .topbar .header-search {
        order: 3;
        width: 100%;
        max-width: none;
    }

@media (min-width: 992px) {
    .topbar {
        flex-wrap: nowrap;
    }

        .topbar .header-search {
            order: 0;
            width: auto;
            flex: 1;
            margin: 0 1rem;
            max-width: 420px;
        }
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-eyebrow {
    margin: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

.topbar-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-chip-btn {
    border: none;
    cursor: pointer;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.page-content {
    flex: 1;
    padding: 1.25rem;
}

.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.footer-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

    .footer-links a {
        color: var(--text-muted);
        text-decoration: none;
    }

        .footer-links a:hover {
            color: var(--text);
        }

.sidebar-toggle {
    display: inline-flex;
}

.sidebar-overlay {
    display: none;
}

/* Header search & icons */
.header-search {
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    min-width: 280px;
    max-width: 420px;
    flex: 1;
}

    .header-search i {
        color: var(--text-muted);
        font-size: 0.95rem;
    }

.header-search-input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 0.9rem;
    color: var(--text);
}

.header-icon-btn {
    position: relative;
    color: #475569;
    border-color: var(--border);
    background: #fff;
}

    .header-icon-btn:hover {
        color: var(--primary);
        border-color: #c7d2fe;
        background: var(--primary-light);
    }

.header-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.header-dropdown {
    min-width: 260px;
}

    .header-dropdown .dropdown-header {
        font-weight: 700;
        color: var(--text);
    }

.topbar-titles {
    min-width: 0;
}

.change-password-panel {
    max-width: 720px;
}

.login-container-narrow {
    grid-template-columns: 1fr !important;
    max-width: 480px;
}

/* Desktop sidebar collapse */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    [dir="rtl"] body.sidebar-collapsed .sidebar {
        transform: translateX(var(--sidebar-width));
    }
}

/* Panels & pages */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-title {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.page-subtitle {
    margin: 0;
    color: var(--text-muted);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #334155;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

    .stat-card p {
        margin: 0 0 0.35rem;
        color: var(--text-muted);
        font-size: 0.85rem;
        font-weight: 600;
    }

    .stat-card h3 {
        margin: 0;
        font-size: 1.75rem;
        font-weight: 800;
    }

.stat-icon {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    opacity: 0.2;
}

.stat-card.primary {
    border-top: 3px solid var(--primary);
}

.stat-card.success {
    border-top: 3px solid #10b981;
}

.stat-card.warning {
    border-top: 3px solid #f59e0b;
}

.stat-card.info {
    border-top: 3px solid var(--accent);
}

.table-toolbar {
    margin-bottom: 0.75rem;
}

.student-table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom-width: 1px;
}

.student-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.avatar-chip {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.status-pill {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}

    .status-pill.active {
        background: #dcfce7;
        color: #166534;
    }

.quick-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    transition: border-color 0.2s, background 0.2s;
}

    .quick-link:hover {
        border-color: #c7d2fe;
        background: var(--primary-light);
        color: var(--primary-dark);
    }

    .quick-link i {
        font-size: 1.1rem;
        color: var(--primary);
    }

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

    .btn-primary:hover {
        background: var(--primary-dark);
        border-color: var(--primary-dark);
    }

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0f172a 0%, #312e81 45%, #1e293b 100%);
    position: relative;
    overflow: hidden;
}

.login-bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.35;
}

.shape-1 {
    width: 320px;
    height: 320px;
    background: #6366f1;
    top: -80px;
    right: -60px;
}

.shape-2 {
    width: 280px;
    height: 280px;
    background: #22d3ee;
    bottom: -60px;
    left: -40px;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: #a78bfa;
    top: 40%;
    left: 30%;
}

.login-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 960px;
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 1;
}

.login-showcase {
    padding: 2.5rem;
    color: #e2e8f0;
    background: linear-gradient(160deg, rgba(99, 102, 241, 0.25), rgba(34, 211, 238, 0.1));
}

.showcase-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 1.25rem;
}

.showcase-content h2 {
    font-size: 1.65rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: #fff;
}

.showcase-content p {
    color: #cbd5e1;
    line-height: 1.6;
}

.showcase-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
}

    .showcase-features li {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.65rem;
        color: #e2e8f0;
    }

    .showcase-features i {
        color: #34d399;
    }

.login-card {
    background: #fff;
    padding: 2.25rem;
}

.login-card-header h1 {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0 0 0.35rem;
}

.login-card-header p {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}

.login-logo {
    width: 52px;
    height: 52px;
    margin-bottom: 0.75rem;
}

.login-form .form-control {
    border-radius: 10px;
    border-color: var(--border);
    min-height: 52px;
}

.login-form .form-floating > label {
    padding-top: 0.9rem;
}

.password-field {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-muted);
    z-index: 5;
    padding: 0.25rem;
}

.login-forgot {
    font-size: 0.88rem;
    text-decoration: none;
}

.btn-login {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border: none;
    color: #fff;
    font-weight: 700;
    min-height: 48px;
    border-radius: 10px;
}

    .btn-login:hover {
        color: #fff;
        filter: brightness(1.05);
        transform: translateY(-1px);
    }

.login-demo-hint {
    margin-top: 1.25rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Mobile */
@media (max-width: 991.98px) {
    .main-shell {
        margin-inline-start: 0;
    }

    .sidebar {
        transform: translateX(calc(-1 * 100%));
        width: min(280px, 85vw);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1035;
    }

    .login-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .page-content {
        padding: 1rem;
    }

    .topbar-title {
        font-size: 1rem;
    }

    .login-card {
        padding: 1.5rem;
    }
}

.language-switcher .dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.login-lang-bar {
    position: fixed;
    top: 1rem;
    inset-inline-end: 1rem;
    z-index: 1100;
}

.rtl-layout {
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
}

[dir="rtl"] .side-group summary::after {
    float: left;
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .sub-nav {
    padding-inline-start: 2rem;
    padding-inline-end: 0;
}

[dir="rtl"] .stat-icon {
    right: auto;
    left: 1rem;
}

[dir="rtl"] .password-toggle {
    right: auto;
    left: 12px;
}

[dir="rtl"] .student-cell,
[dir="rtl"] .topbar-left,
[dir="rtl"] .topbar-right,
[dir="rtl"] .page-header,
[dir="rtl"] .form-actions,
[dir="rtl"] .footer-links {
    flex-direction: row-reverse;
}

@media (max-width: 991.98px) {
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    [dir="rtl"] body.sidebar-open .sidebar {
        transform: translateX(0);
    }
}
.dataTables_wrapper {
    padding: 0;
}

table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
}

    table.dataTable thead th {
        position: sticky;
        top: 0;
        z-index: 5;
        background: #0d6efd;
        color: #fff;
        font-weight: 600;
        white-space: nowrap;
    }

    table.dataTable tbody td {
        vertical-align: middle;
    }

    table.dataTable tbody tr:hover {
        background: #eef6ff;
    }

    table.dataTable tbody tr.shown {
        background: #e8f4ff;
    }


/* RTL / Arabic support */
body.rtl {
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
}

    body.rtl .header-inner,
    body.rtl .sidebar-nav,
    body.rtl .nav-item,
    body.rtl .nav-group {
        text-align: right;
    }

        body.rtl .nav-group.active .chevron {
            transform: rotate(180deg);
        }

    body.rtl .dropdown-menu {
        text-align: right;
    }

    body.rtl .table-modern th,
    body.rtl .table-modern td {
        text-align: right;
    }

    body.rtl .form-label,
    body.rtl .form-check-label {
        text-align: right;
        display: block;
    }

    body.rtl .btn,
    body.rtl .card-modern h4,
    body.rtl .card-modern h5 {
        text-align: inherit;
    }

    body.rtl .login-card,
    body.rtl .stat-card {
        text-align: right;
    }

        body.rtl .login-card .text-center {
            text-align: center !important;
        }

.offline-card {
    max-width: 420px;
}

.offline-icon {
    font-size: 3rem;
}

body.rtl .content-area .text-end {
    text-align: left !important;
}

body.rtl .content-area .text-start {
    text-align: right !important;
}

body.rtl .nav-submenu {
    padding-inline-start: 0;
    padding-inline-end: 2.5rem;
}

body.rtl .sidebar {
    border-inline-end: 0;
    border-inline-start: 1px solid var(--border);
}

@media (max-width: 768px) {
    body.rtl .app-shell.sidebar-open .sidebar {
        inset-inline-start: 0;
        inset-inline-end: auto;
    }
}