/* ===================================================
   EduRAG SMAN 2 Surabaya - Modern Solid Color Design System
   Style: No Gradients, Vibrant Solid Colors (Sky Blue, Emerald Green, Amber Yellow, Coral Red, Dark Slate)
   =================================================== */

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

:root {
    /* Base Backgrounds */
    --bg-page: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f8fafc;
    
    /* Text Hierarchy */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Border Colors */
    --border-subtle: #e2e8f0;
    --border-medium: #cbd5e1;
    --border-strong: #94a3b8;

    /* Theme Solid Colors (NO GRADIENTS) */
    /* 1. Biru Muda / Sky Blue (Primary) */
    --c-blue: #2563eb;
    --c-blue-hover: #1d4ed8;
    --c-blue-light: #eff6ff;
    --c-blue-border: #93c5fd;
    --c-blue-text: #1d4ed8;
    --c-blue-badge: #dbeafe;

    /* 2. Hijau / Emerald (Success & Growth) */
    --c-green: #059669;
    --c-green-hover: #047857;
    --c-green-light: #ecfdf5;
    --c-green-border: #6ee7b7;
    --c-green-text: #065f46;
    --c-green-badge: #d1fae5;

    /* 3. Kuning / Amber (Warning & Attention) */
    --c-yellow: #d97706;
    --c-yellow-hover: #b45309;
    --c-yellow-light: #fffbeb;
    --c-yellow-border: #fcd34d;
    --c-yellow-text: #92400e;
    --c-yellow-badge: #fef3c7;

    /* 4. Merah / Coral Rose (Danger & Action) */
    --c-red: #e11d48;
    --c-red-hover: #be123c;
    --c-red-light: #fff1f2;
    --c-red-border: #fda4af;
    --c-red-text: #9f1239;
    --c-red-badge: #ffe4e6;

    /* 5. Ungu / Indigo (AI & Special) */
    --c-purple: #7c3aed;
    --c-purple-hover: #6d28d9;
    --c-purple-light: #f5f3ff;
    --c-purple-border: #c4b5fd;
    --c-purple-text: #5b21b6;
    --c-purple-badge: #ede9fe;

    /* Sidebar SMAN 2 School Green Solid (Matching Reference) */
    --sidebar-bg: #05682b;
    --sidebar-surface: rgba(255, 255, 255, 0.14);
    --sidebar-border: #045222;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: rgba(255, 255, 255, 0.85);
    --sidebar-active-bg: #ffffff;
    --sidebar-active-text: #05682b;

    /* Shadows (Clean & Crisp) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
    --shadow-hover: 0 12px 20px -3px rgba(15, 23, 42, 0.12);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

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

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

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

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-page);
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* ===================================================
   SIDEBAR (SMAN 2 School Green matching Reference UI)
   =================================================== */
.sidebar {
    width: 270px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
}

.sidebar-header {
    padding: 24px 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background-color: var(--sidebar-bg);
}

.sidebar-logo {
    width: 86px;
    height: auto;
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.sidebar-brand-title {
    color: #ffffff;
    font-weight: 800;
    font-size: 13.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.8px;
    padding: 14px 12px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #ffffff;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    margin-bottom: 4px;
    position: relative;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    transform: translateX(2px);
}

/* Active State: Clean White Button with Green Text and Green Icon */
.nav-link.active {
    background-color: #ffffff !important;
    color: #05682b !important;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.nav-link.active .icon,
.nav-link.active i,
.nav-link.active svg {
    color: #05682b !important;
}

.nav-link .icon {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    color: #ffffff;
    transition: transform 0.15s ease;
}

.nav-link:hover .icon {
    transform: scale(1.08);
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    background-color: #045222;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: #ffffff;
    color: #05682b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14.5px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.user-meta {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-top: 2px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.role-admin { background-color: #f43f5e; color: #ffffff; }
.role-guru  { background-color: #2563eb; color: #ffffff; }
.role-siswa { background-color: #059669; color: #ffffff; }

/* ===================================================
   MAIN CONTENT AREA & TOPBAR
   =================================================== */
.main-wrapper {
    flex: 1;
    margin-left: 270px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-page);
    width: calc(100% - 270px);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.topbar {
    height: 68px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-xs);
    width: 100%;
    box-sizing: border-box;
}

.page-title {
    font-size: 19px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-title::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 20px;
    background-color: var(--c-blue);
    border-radius: 4px;
    flex-shrink: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.content-body {
    flex: 1;
    padding: 28px 32px 60px;
    max-width: 1400px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ===================================================
   COLORFUL SOLID CARD SYSTEM (NO GRADIENTS)
   =================================================== */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Solid Flat Themed Cards */
.card-blue {
    background-color: var(--c-blue-light) !important;
    border: 1.5px solid var(--c-blue-border) !important;
    border-left: 5px solid var(--c-blue) !important;
    color: var(--c-blue-text) !important;
}

.card-emerald {
    background-color: var(--c-green-light) !important;
    border: 1.5px solid var(--c-green-border) !important;
    border-left: 5px solid var(--c-green) !important;
    color: var(--c-green-text) !important;
}

.card-amber {
    background-color: var(--c-yellow-light) !important;
    border: 1.5px solid var(--c-yellow-border) !important;
    border-left: 5px solid var(--c-yellow) !important;
    color: var(--c-yellow-text) !important;
}

.card-purple {
    background-color: var(--c-purple-light) !important;
    border: 1.5px solid var(--c-purple-border) !important;
    border-left: 5px solid var(--c-purple) !important;
    color: var(--c-purple-text) !important;
}

.card-rose {
    background-color: var(--c-red-light) !important;
    border: 1.5px solid var(--c-red-border) !important;
    border-left: 5px solid var(--c-red) !important;
    color: var(--c-red-text) !important;
}

.card-slate {
    background-color: #f8fafc !important;
    border: 1.5px solid var(--border-subtle) !important;
    border-left: 5px solid #475569 !important;
    color: #1e293b !important;
}

.card-white {
    background-color: #ffffff !important;
    border: 1px solid var(--border-subtle) !important;
}

/* ===================================================
   VIBRANT SOLID STAT CARDS
   =================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.card-blue .stat-icon-wrapper {
    background-color: var(--c-blue);
    color: #ffffff;
}

.card-emerald .stat-icon-wrapper {
    background-color: var(--c-green);
    color: #ffffff;
}

.card-amber .stat-icon-wrapper {
    background-color: var(--c-yellow);
    color: #ffffff;
}

.card-purple .stat-icon-wrapper {
    background-color: var(--c-purple);
    color: #ffffff;
}

.card-rose .stat-icon-wrapper {
    background-color: var(--c-red);
    color: #ffffff;
}

.card-slate .stat-icon-wrapper {
    background-color: #475569;
    color: #ffffff;
}

.stat-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.stat-val {
    font-size: 34px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 6px;
}

.stat-sub {
    font-size: 12.5px;
    font-weight: 500;
    opacity: 0.85;
}

/* ===================================================
   BUTTONS (Solid Flat, Bold & Interactive)
   =================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1.5px solid transparent;
    text-decoration: none;
    transition: all 0.18s ease;
    box-shadow: var(--shadow-xs);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background-color: var(--c-blue);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--c-blue-hover);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-success {
    background-color: var(--c-green);
    color: #ffffff;
}
.btn-success:hover {
    background-color: var(--c-green-hover);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
}

.btn-warning {
    background-color: var(--c-yellow);
    color: #ffffff;
}
.btn-warning:hover {
    background-color: var(--c-yellow-hover);
    color: #ffffff;
}

.btn-danger {
    background-color: var(--c-red);
    color: #ffffff;
}
.btn-danger:hover {
    background-color: var(--c-red-hover);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(225, 29, 72, 0.3);
}

.btn-purple {
    background-color: var(--c-purple);
    color: #ffffff;
}
.btn-purple:hover {
    background-color: var(--c-purple-hover);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
}

.btn-outline {
    background-color: #ffffff;
    border-color: var(--border-medium);
    color: var(--text-primary);
}
.btn-outline:hover {
    background-color: #f1f5f9;
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

/* ===================================================
   BADGES (Solid Clean & Vivid)
   =================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    letter-spacing: 0.2px;
}

.badge-blue     { background-color: var(--c-blue-badge); color: var(--c-blue-text); border: 1px solid var(--c-blue-border); }
.badge-success  { background-color: var(--c-green-badge); color: var(--c-green-text); border: 1px solid var(--c-green-border); }
.badge-emerald  { background-color: var(--c-green-badge); color: var(--c-green-text); border: 1px solid var(--c-green-border); }
.badge-warning  { background-color: var(--c-yellow-badge); color: var(--c-yellow-text); border: 1px solid var(--c-yellow-border); }
.badge-amber    { background-color: var(--c-yellow-badge); color: var(--c-yellow-text); border: 1px solid var(--c-yellow-border); }
.badge-danger   { background-color: var(--c-red-badge); color: var(--c-red-text); border: 1px solid var(--c-red-border); }
.badge-rose     { background-color: var(--c-red-badge); color: var(--c-red-text); border: 1px solid var(--c-red-border); }
.badge-purple   { background-color: var(--c-purple-badge); color: var(--c-purple-text); border: 1px solid var(--c-purple-border); }
.badge-secondary{ background-color: #f1f5f9; color: #475569; border: 1px solid var(--border-subtle); }

/* ===================================================
   TABLES (Clean, Solid Header, Crisp Row Separation)
   =================================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    display: block;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
    font-size: 13.5px;
    background-color: #ffffff;
}

.table th {
    background-color: #f8fafc;
    color: #1e293b;
    font-weight: 700;
    text-align: left;
    padding: 13px 18px;
    border-bottom: 2px solid var(--border-subtle);
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.table td {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background-color: #f8fafc;
}

.table td.cell-wrap,
.table td.text-wrap {
    white-space: normal;
    min-width: 220px;
    max-width: 420px;
}

/* ===================================================
   FORMS & INPUTS
   =================================================== */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 7px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid var(--border-medium);
    border-radius: var(--radius-md);
    background-color: #ffffff;
    color: var(--text-primary);
    outline: none;
    transition: all 0.18s ease;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.12);
}

/* ===================================================
   ALERTS (Solid Left Border & Clean Tone)
   =================================================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background-color: var(--c-green-light);
    border: 1px solid var(--c-green-border);
    border-left: 5px solid var(--c-green);
    color: var(--c-green-text);
}

.alert-error {
    background-color: var(--c-red-light);
    border: 1px solid var(--c-red-border);
    border-left: 5px solid var(--c-red);
    color: var(--c-red-text);
}

.alert-info {
    background-color: var(--c-blue-light);
    border: 1px solid var(--c-blue-border);
    border-left: 5px solid var(--c-blue);
    color: var(--c-blue-text);
}

/* ===================================================
   AI TUTOR CHAT UI (Vibrant Modern Container)
   =================================================== */
.chat-container {
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    height: 620px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.chat-header {
    padding: 16px 22px;
    border-bottom: 1.5px solid var(--c-green-border);
    background-color: var(--c-green);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background-color: #f8fafc;
}

.chat-bubble {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    box-shadow: var(--shadow-xs);
}

.bubble-user {
    align-self: flex-end;
    background-color: #0f172a;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.bubble-ai {
    align-self: flex-start;
    background-color: #ffffff;
    border: 1.5px solid var(--border-subtle);
    border-left: 4px solid var(--c-green);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.citation-box {
    margin-top: 12px;
    padding: 10px 14px;
    background-color: var(--c-yellow-light);
    border: 1px solid var(--c-yellow-border);
    border-left: 4px solid var(--c-yellow);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--c-yellow-text);
    font-weight: 600;
}

.chat-quick-actions {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background-color: #ffffff;
    border-top: 1px solid var(--border-subtle);
}

.quick-btn {
    white-space: nowrap;
    font-size: 12px;
    padding: 7px 14px;
    background-color: var(--c-blue-light);
    border: 1px solid var(--c-blue-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--c-blue-text);
    font-weight: 700;
    transition: all 0.15s;
}

.quick-btn:hover {
    background-color: var(--c-blue);
    color: #ffffff;
}

.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 12px;
    background-color: #ffffff;
}

/* ===================================================
   MODAL COMPONENT
   =================================================== */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-box {
    background: #ffffff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-hover);
    border: 1.5px solid var(--border-subtle);
    overflow: hidden;
    animation: modalSlideIn 0.22s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 18px 22px;
    background-color: #0f172a;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16.5px;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
}

.modal-body {
    padding: 24px;
    max-height: calc(85vh - 130px);
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
}

/* ===================================================
   MICRO-ANIMATIONS & SPINNERS
   =================================================== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin,
.animate-spin,
svg.spin,
i.spin {
    display: inline-block !important;
    animation: spin 0.85s linear infinite !important;
    transform-origin: 50% 50% !important;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2.5px solid #bfdbfe;
    border-top-color: var(--c-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* Sidebar Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 998;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive Overhaul (Eliminates any mobile offset/horizontal overflow bug) */
@media (max-width: 992px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .app-container {
        display: block !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        position: relative !important;
    }

    .sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        pointer-events: none;
        z-index: 999;
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        box-shadow: 0 0 35px rgba(0,0,0,0.5);
    }

    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        display: block !important;
    }

    .topbar {
        padding: 0 14px !important;
        height: 60px !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .page-title {
        font-size: 15px !important;
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .page-title::before {
        display: none !important;
    }

    .topbar-right {
        gap: 8px !important;
        flex-shrink: 0 !important;
    }

    .topbar-date {
        display: none !important;
    }

    .content-body {
        padding: 16px 14px 40px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
    }

    .card {
        padding: 16px 14px !important;
        margin-bottom: 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
    }

    .stat-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    #sidebarToggle {
        display: inline-flex !important;
    }

    /* Auto-collapse any multi-column inline grids to 1 column on mobile */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .cbt-container {
        grid-template-columns: 1fr !important;
    }

    /* Mobile Table Horizontal Scroll Engine (Never squish or stack letters) */
    .table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
    }

    .table {
        min-width: 650px !important;
        width: max-content !important;
    }

    .table th,
    .table td {
        white-space: nowrap !important;
        padding: 12px 14px !important;
        font-size: 13px !important;
    }

    .table td.cell-wrap,
    .table td.text-wrap {
        white-space: normal !important;
    }
}

/* ===================================================
   PAGINATION SYSTEM
   =================================================== */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.pagination {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.page-item {
    display: inline-block;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    background-color: #ffffff;
    border: 1.5px solid var(--border-medium);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s ease;
}

.page-link:hover {
    background-color: var(--c-blue-light);
    border-color: var(--c-blue);
    color: var(--c-blue);
}

.page-item.active .page-link {
    background-color: var(--c-blue);
    border-color: var(--c-blue);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
    background-color: #f8fafc;
    border-color: var(--border-subtle);
}

/* ===================================================
   CBT EXAM QUESTION SLIDER & NAVIGATION GRID
   =================================================== */
.cbt-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .cbt-container {
        grid-template-columns: 1fr;
    }
}

.cbt-nav-card {
    background: #ffffff;
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 22px;
    position: sticky;
    top: 90px;
    box-shadow: var(--shadow-sm);
}

.cbt-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px;
}

.cbt-num-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    border: 1.5px solid var(--border-subtle);
    background: #f8fafc;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cbt-num-btn:hover {
    border-color: var(--c-blue);
    color: var(--c-blue);
}

.cbt-num-btn.active {
    border-color: var(--c-blue) !important;
    background-color: var(--c-blue) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.cbt-num-btn.answered {
    background-color: var(--c-green);
    border-color: var(--c-green);
    color: #ffffff;
}

.cbt-num-btn.ragu {
    background-color: var(--c-yellow);
    border-color: var(--c-yellow);
    color: #ffffff;
}

.cbt-question-item {
    display: none;
}

.cbt-question-item.active {
    display: block;
    animation: fadeInQ 0.2s ease-out;
}

@keyframes fadeInQ {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

