/* Saint John Paul II Schools CBT - Ultra-Premium Offline UI Design System */

:root {
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    
    /* Harmonious Curated Colors */
    --primary-hsl: 224, 76%, 48%;
    --primary: hsl(var(--primary-hsl));
    --primary-hover: hsl(224, 84%, 40%);
    --primary-light: hsl(224, 100%, 97%);
    --primary-glow: rgba(79, 70, 229, 0.25);
    
    --secondary-hsl: 215, 25%, 27%;
    --secondary: hsl(var(--secondary-hsl));
    
    --bg-dark: #090d16;
    --sidebar-bg: #0f172a;
    --background: #f1f5f9;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.85);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    
    --success: #059669;
    --success-bg: #ecfdf5;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #e11d48;
    --danger-bg: #fff1f2;
    --info: #0284c7;
    --info-bg: #f0f9ff;

    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 30px -10px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 8px 25px -3px var(--primary-glow);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 25px rgba(15, 23, 42, 0.15);
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    background: #ffffff;
    text-align: center;
    border-bottom: 1px solid rgba(226, 232, 240, 0.2);
}

.sidebar-header img {
    max-width: 100%;
    height: auto;
    max-height: 52px;
    object-fit: contain;
}

.sidebar-nav {
    padding: 1.25rem 0.85rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.15rem;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.925rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

.nav-item.active, .nav-item:focus {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
}

/* Main Content & Navbar */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.header-navbar {
    height: 72px;
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: #f8fafc;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.content-body {
    padding: 2.5rem;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Stat Cards & Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.75rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5 0%, #06b6d4 100%);
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary);
    margin-top: 0.4rem;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Card Tables & Table Responsiveness */
.card-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 2rem;
    width: 100%;
}

.card-table h3 {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 700;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 560px; /* Prevents pages from becoming infinitely long */
    -webkit-overflow-scrolling: touch;
}

.table-responsive::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
    min-width: 600px;
}

.table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #f8fafc;
    padding: 0.9rem 1.25rem;
    font-size: 0.775rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    transition: var(--transition);
    vertical-align: middle;
}

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

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

.table td .btn,
.table td .badge,
.table td code,
.table td strong {
    white-space: nowrap;
}

/* Responsiveness across Laptop / Desktop Monitor Sizes */
@media (max-width: 1280px) {
    .sidebar {
        width: 240px;
    }
    .header-navbar {
        padding: 0 1.5rem;
    }
    .content-body {
        padding: 1.5rem 1.25rem;
        max-width: 100%;
    }
    div[style*="grid-template-columns: 1fr 1fr 1.2fr"],
    div[style*="grid-template-columns: 1.2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 210px;
    }
    .header-navbar {
        padding: 0 1.25rem;
    }
    .content-body {
        padding: 1.25rem 1rem;
        max-width: 100%;
    }
}

@media (max-width: 850px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        min-height: auto;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.5rem;
        gap: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    .nav-item {
        white-space: nowrap;
        padding: 0.5rem 0.85rem;
        font-size: 0.85rem;
    }
    .header-navbar {
        height: auto;
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .content-body {
        padding: 1rem 0.75rem;
    }
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.35rem;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -3px var(--primary-glow);
    filter: brightness(1.08);
}

.btn-secondary {
    background: #ffffff;
    border: 1px solid var(--border-dark);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    font-size: 0.775rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
}

.badge-success { background-color: #dcfce7; color: #15803d; }
.badge-warning { background-color: #fef3c7; color: #b45309; }
.badge-danger { background-color: #ffe4e6; color: #be123c; }
.badge-info { background-color: #e0f2fe; color: #0369a1; }
.badge-primary { background-color: #e0e7ff; color: #4338ca; }

/* Forms */
.form-group {
    margin-bottom: 1.35rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font-family);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-body {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile Sidebar Backdrop & Toggle Controls */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

.mobile-menu-toggle {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.mobile-menu-toggle:hover, .mobile-menu-toggle:active {
    background: var(--primary);
    transform: scale(0.98);
}

/* Mobile & Tablet Responsive Media Queries */
@media (max-width: 1024px) {
    .content-body {
        padding: 1.5rem;
    }
    
    .header-navbar {
        padding: 0 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .app-container {
        position: relative;
    }

    .mobile-menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-header {
        position: relative;
    }

    .sidebar-close-btn {
        display: block !important;
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: transparent;
        border: none;
        color: #64748b;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .header-navbar {
        height: auto;
        min-height: 64px;
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .header-navbar > div {
        font-size: 0.85rem;
    }

    .user-profile-widget {
        width: 100%;
        justify-content: space-between;
        padding: 0.4rem 0.85rem;
        font-size: 0.85rem;
        margin-top: 0.25rem;
    }

    .content-body {
        padding: 1rem 0.75rem;
    }

    /* Grids & Cards Stacking */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .card {
        padding: 1.15rem;
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-header .btn-group,
    .card-header div:has(button) {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Tables Optimization */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
    }

    .table {
        min-width: 600px;
        font-size: 0.875rem;
    }

    .table th, .table td {
        padding: 0.65rem 0.75rem;
        white-space: nowrap;
    }

    /* Form Controls on Mobile */
    .form-control, select.form-control, input.form-control {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
        padding: 0.65rem 0.85rem;
    }

    /* Flex Containers Side by Side converting to Column */
    div[style*="grid-template-columns"],
    div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
    }

    /* Action Buttons on Mobile */
    .btn {
        padding: 0.65rem 1rem;
        min-height: 44px; /* Touch-friendly tap target */
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Modals Responsive */
    .modal-content {
        width: 95% !important;
        margin: 1rem auto !important;
        padding: 1.25rem !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-navbar {
        padding: 0.5rem 0.75rem;
    }

    .nav-item {
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.35rem;
    }

    .card-header h3, .card-header h2 {
        font-size: 1.15rem;
    }
}

/* Student Mobile Touch Cards & Container Toggles */
.mobile-exam-cards-container {
    display: none;
    padding: 1rem;
}

.student-exam-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
    transition: var(--transition);
}

.student-exam-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.desktop-exam-table-container {
    display: block;
}

@media (max-width: 768px) {
    .mobile-exam-cards-container {
        display: block;
    }
    .desktop-exam-table-container {
        display: none;
    }
}


