/**
 * Exam Portal - Modern UI (Synced with StudentV2)
 * Bootstrap 5 + Sidebar Navigation
 */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    /* Header/card/table gradient – matches sidebar blue for consistent theme */
    --header-gradient: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    --sidebar-width: 220px; /* Slimmer sidebar */
    --topbar-height: 60px;
    --transition-speed: 0.3s;
    --border-radius: 12px;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: #f5f7fa;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========================================
   PAGE WRAPPER
   ======================================== */
.page-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ========================================
   SIDEBAR (EXACTLY LIKE STUDENTV2)
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
    color: #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

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

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.sidebar-header h4 {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.sidebar-user {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-user img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-info .name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .role-badge {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 2px;
}

/* SIDEBAR NAVIGATION */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav > ul > li > a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav > ul > li > a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-left-color: #60a5fa;
}

.sidebar-nav > ul > li > a.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-left-color: #60a5fa;
    font-weight: 600;
}

.sidebar-nav > ul > li > a i {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
    text-align: center;
}

.sidebar-nav > ul > li > a span {
    flex: 1;
}

/* SIDEBAR OVERLAY (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    transition: opacity 0.3s ease;
}

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

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* MOBILE TOP BAR - Hidden on desktop */
.mobile-topbar {
    display: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Ensure sidebar is visible ONLY on desktop */
@media (min-width: 769px) {
    .sidebar {
        position: relative !important;
        transform: none !important;
        visibility: visible !important;
        display: flex !important;
        width: var(--sidebar-width) !important; /* 220px */
    }
    
    /* Adjust main content for slimmer sidebar */
    .main-content {
        width: calc(100% - var(--sidebar-width));
    }
}

.content-wrapper {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* ========================================
   CARDS (EXAM DASHBOARD)
   ======================================== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
}

/* Card header: dark bg → white text for proper contrast (WCAG) */
.card-header {
    background: var(--header-gradient);
    color: #ffffff;
    padding: 15px 20px;
    font-weight: 600;
    border: none;
}
.card-header,
.card-header *,
.card-header a,
.card-header i,
.card-header .badge {
    color: #ffffff !important;
}
.card-header .badge.bg-light {
    background-color: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
}

/* Card body: light bg → dark text for proper contrast */
.card-body {
    padding: 20px;
    background: #ffffff;
    color: #212529;
}
.card-body a {
    color: var(--primary-color);
}
.card-body .text-muted {
    color: #6c757d !important;
}

/* ========================================
   DESKTOP TABLE STYLING
   ======================================== */
.table {
    margin-bottom: 0;
}

/* Table header: dark bg → white text for proper contrast */
.table thead th {
    background: var(--header-gradient);
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 15px;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
}
.table thead th,
.table thead th * {
    color: #ffffff !important;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table td {
    padding: 15px;
    vertical-align: middle;
    border-color: #e9ecef;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========================================
   MOBILE RESPONSIVE (< 768px)
   ======================================== */
@media (max-width: 768px) {
    /* SIDEBAR - Hidden by default, slide from left when opened */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(280px, 70vw) !important; /* Max 280px or 70% screen */
        transform: translateX(-100%) !important; /* Hidden by default */
        z-index: 1055 !important; /* Above backdrop */
        transition: transform var(--transition-speed) ease;
        display: flex !important; /* Keep structure */
        visibility: hidden !important; /* Hidden by default */
    }

    /* When offcanvas is shown by Bootstrap */
    .sidebar.show,
    .sidebar.showing {
        transform: translateX(0) !important;
        visibility: visible !important;
    }
    
    /* Offcanvas close button */
    .offcanvas-header {
        padding: 15px 20px;
        background: rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .offcanvas-header .offcanvas-title {
        color: white;
        font-weight: 600;
        font-size: 16px;
    }
    
    .offcanvas-header .btn-close {
        filter: invert(1);
        opacity: 0.8;
    }

    /* SHOW mobile topbar */
    .mobile-topbar {
        display: flex !important;
    }

    /* MAIN CONTENT - Full width */
    .main-content {
        width: 100%;
    }

    .content-wrapper {
        padding: 15px 10px;
    }

    /* OVERLAY */
    .sidebar-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
    }

    .sidebar-overlay.show {
        opacity: 1;
        pointer-events: all;
    }
    
    /* ========================================
       MOBILE STACKED TABLES (GLOBAL)
       ======================================== */
    
    /* Force left alignment for all content */
    .content-wrapper {
        text-align: left !important;
    }
    
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .col-md-12 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Hide table header on mobile */
    table thead {
        display: none !important;
    }
    
    /* Make each row a card - LEFT ALIGNED */
    table tr {
        display: block;
        margin-bottom: 20px;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border: 1px solid #dee2e6;
        border-radius: 10px;
        padding: 15px;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        text-align: left !important;
    }
    
    /* Style each cell as a row */
    table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px solid #f0f0f0;
        text-align: left !important;
        margin-left: 0 !important;
    }
    
    table td:last-child {
        border-bottom: none;
    }
    
    /* Show label before content - LEFT ALIGNED */
    table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #495057;
        text-align: left !important;
        margin-right: 10px;
        flex: 0 0 110px;
        min-width: 110px;
    }
    
    /* Value part - RIGHT ALIGNED within flex */
    table td > * {
        text-align: right;
    }
    
    /* Action buttons full width, centered text */
    table td[data-label="Action"] {
        flex-direction: column;
        align-items: stretch;
        text-align: center !important;
    }
    
    table td[data-label="Action"]::before {
        margin-bottom: 8px;
        text-align: center !important;
    }
    
    table td[data-label="Action"] .btn {
        width: 100%;
        margin-top: 5px;
        text-align: center !important;
    }
    
    table td[data-label="Action"] br {
        display: none;
    }
    
    /* Adjust badges and small text */
    table td .badge {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    table td small {
        display: block;
        margin-top: 4px;
        text-align: right;
    }
    
    /* Ensure table container is left-aligned */
    .table-responsive {
        margin-left: 0 !important;
        margin-right: 0 !important;
        text-align: left !important;
    }
    
    table {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ========================================
   examV2cf SPA (login + exam room)
   ======================================== */
body.exam-app-body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: #f4f6f9;
    margin: 0;
    min-height: 100vh;
}

.view-hidden {
    display: none !important;
}

body.exam-login-only #appShell {
    display: none !important;
}

body:not(.exam-login-only) #view-login {
    display: none !important;
}

body.exam-in-room .sidebar,
body.exam-in-room .mobile-topbar {
    display: none !important;
}

body.exam-in-room .main-content {
    width: 100% !important;
}

body.exam-in-room .content-wrapper {
    padding-top: 10px;
}

/* Login page (examV2/login.php) */
.login-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 420px;
    width: 100%;
}

.login-card .logo-section {
    text-align: center;
    margin-bottom: 24px;
}

.login-card .logo-section img {
    max-width: 100%;
    height: auto;
    margin-bottom: 16px;
}

.login-card .logo-section h2 {
    color: #333;
    font-size: 1.35rem;
    margin-bottom: 8px;
}

.login-card .logo-section p {
    color: #666;
    font-size: 14px;
    margin-bottom: 0;
}

.login-card .social-links {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.login-card .social-links a {
    display: inline-block;
    margin: 0 8px;
    color: #667eea;
    font-size: 20px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.login-card .social-links a:hover {
    color: #764ba2;
    transform: translateY(-2px);
}

.sidebar-avatar {
    object-fit: cover;
    background: #fff;
}

.social-links-header a {
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-block;
    margin: 0 5px;
    font-size: 18px;
}

.social-links-header a:hover {
    transform: translateY(-2px);
    opacity: 0.85;
}

.student-info-table td:first-child {
    font-weight: 600;
    color: #495057;
    width: 40%;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.paper-demo-badge {
    font-size: 11px;
    vertical-align: middle;
}

