/* TCF Test Enhanced Layout - Professional Test-Taking Experience */
/* Version 2.0 - Enhanced Desktop Layout with Better Responsiveness */

/* ========================================
   CSS Variables for Consistent Design
   ======================================== */
:root {
    --tcf-primary: #0056d2;
    --tcf-primary-hover: #0047b3;
    --tcf-success: #28a745;
    --tcf-success-light: #d4edda;
    --tcf-success-border: #198754;
    --tcf-danger: #dc3545;
    --tcf-warning: #ffc107;
    --tcf-info: #17a2b8;
    --tcf-secondary: #6c757d;
    --tcf-light: #f8f9fa;
    --tcf-dark: #212529;
    --tcf-border: #dee2e6;
    --tcf-shadow: 0 2px 4px rgba(0,0,0,0.08);
    --tcf-shadow-hover: 0 4px 8px rgba(0,0,0,0.12);
    --tcf-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --tcf-radius: 8px;
    --tcf-radius-lg: 12px;
    --tcf-font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========================================
   Force hide mobile sidebar toggle button
   to prevent overlap with report icon
   ======================================== */
.mobile-sidebar-toggle,
#mobile-sidebar-toggle,
button.mobile-sidebar-toggle.d-lg-none,
button#mobile-sidebar-toggle.mobile-sidebar-toggle.d-lg-none {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* ========================================
   Enhanced 3-Column Desktop Layout
   ======================================== */
@media (min-width: 1200px) {
    /* Main Layout Container - Full Desktop */
    .tcf-exam-ce #tcf-test-screen .exam-layout,
    .tcf-exam-co #tcf-test-screen .exam-layout {
        display: grid !important;
        grid-template-columns: 220px 1fr 320px;
        gap: 24px;
        height: calc(100vh - 40px);
        padding: 20px;
        background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
        overflow: hidden;
    }

    /* Column 1: Enhanced Left Sidebar */
    .tcf-exam-ce #tcf-test-screen .exam-left-sidebar,
    .tcf-exam-co #tcf-test-screen .exam-left-sidebar {
        width: 100% !important;
        display: block !important;
        background: transparent !important;
        border-radius: var(--tcf-radius-lg);
        box-shadow: var(--tcf-shadow);
        overflow: hidden;
        padding: 0 !important;
    }

    /* Remove white space above Questions panel */
    .exam-left-sidebar .sidebar-content {
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
    }

    .exam-left-sidebar .card {
        margin: 0 !important;
        border: none !important;
        background: white !important;
        border-radius: var(--tcf-radius-lg) !important;
        overflow: hidden !important;
    }

    .exam-left-sidebar .card-body {
        padding: 0 !important;
        background: white !important;
    }

    /* Enhanced Progress Header - First Element */
    .exam-left-sidebar .card-header {
        background: linear-gradient(135deg, var(--tcf-primary) 0%, var(--tcf-primary-hover) 100%) !important;
        padding: 16px !important;
        border: none !important;
        border-radius: var(--tcf-radius-lg) var(--tcf-radius-lg) 0 0 !important;
        margin: 0 !important;
        position: relative;
        top: 0;
    }

    .exam-left-sidebar .card-header h6 {
        font-size: 14px !important;
        font-weight: 600 !important;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        color: white !important;
        opacity: 1 !important;
    }

    /* Ensure all text and icons in the header are white */
    .exam-left-sidebar .card-header,
    .exam-left-sidebar .card-header *,
    .exam-left-sidebar .card-header i {
        color: white !important;
    }

    /* Specific targeting for the icon */
    .exam-left-sidebar .card-header .fa-list-ol,
    .exam-left-sidebar .card-header .fas {
        color: white !important;
    }

    /* Enhanced Progress Bar */
    .exam-left-sidebar .progress {
        height: 8px !important;
        background: rgba(255, 255, 255, 0.25) !important;
        border-radius: 4px;
        overflow: hidden;
        margin-top: 12px !important;
    }

    .exam-left-sidebar .progress-bar {
        background: linear-gradient(90deg, #4ade80 0%, #22c55e 100%) !important;
        transition: width 0.5s ease !important;
        box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
    }

    /* Progress Text Enhancement */
    #progress-text {
        display: block;
        margin-top: 8px;
        font-size: 13px !important;
        font-weight: 500;
        color: white !important;
        opacity: 1 !important;
    }

    /* Enhanced Question Navigation Container */
    .question-nav-container {
        height: calc(100vh - 240px);
        overflow-y: auto;
        padding: 16px !important;
        background: var(--tcf-light);
    }

    /* Custom Scrollbar for Question Nav */
    .question-nav-container::-webkit-scrollbar {
        width: 8px;
    }

    .question-nav-container::-webkit-scrollbar-track {
        background: #e9ecef;
        border-radius: 4px;
    }

    .question-nav-container::-webkit-scrollbar-thumb {
        background: #adb5bd;
        border-radius: 4px;
        transition: background 0.3s;
    }

    .question-nav-container::-webkit-scrollbar-thumb:hover {
        background: #868e96;
    }

    /* Enhanced Question Navigation Buttons */
    .question-nav-grid {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0;
    }

    .question-nav-grid .question-nav-btn {
        width: 100% !important;
        height: 44px !important;
        border: 2px solid var(--tcf-border);
        background: white;
        border-radius: var(--tcf-radius);
        font-weight: 600;
        font-size: 15px;
        transition: var(--tcf-transition);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    /* Button States with Better Visual Feedback */
    .question-nav-grid .question-nav-btn:hover {
        transform: translateX(4px);
        border-color: var(--tcf-primary);
        background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%);
        box-shadow: var(--tcf-shadow-hover);
    }

    .question-nav-grid .question-nav-btn.current {
        background: linear-gradient(135deg, var(--tcf-primary) 0%, var(--tcf-primary-hover) 100%);
        border-color: var(--tcf-primary);
        color: white;
        font-weight: 700;
        box-shadow: 0 4px 6px rgba(0, 86, 210, 0.25);
        animation: pulse 2s infinite;
    }

    @keyframes pulse {
        0%, 100% { transform: scale(1); }
        50% { transform: scale(1.02); }
    }

    .question-nav-grid .question-nav-btn.answered {
        background: linear-gradient(135deg, var(--tcf-success-light) 0%, #c3e6cb 100%);
        border-color: var(--tcf-success-border);
        color: #155724;
        position: relative;
    }

    .question-nav-grid .question-nav-btn.answered::after {
        content: "✓";
        position: absolute;
        right: 12px;
        font-size: 16px;
        color: var(--tcf-success);
        font-weight: bold;
    }

    .question-nav-grid .question-nav-btn.current.answered {
        background: linear-gradient(135deg, var(--tcf-success) 0%, #22c55e 100%);
        border-color: var(--tcf-success);
        color: white;
    }

    /* CO Test - Passed State */
    .tcf-exam-co .question-nav-grid .question-nav-btn.passed {
        background: linear-gradient(135deg, #f1f3f5 0%, #e9ecef 100%) !important;
        border-color: #ced4da !important;
        color: #868e96 !important;
        cursor: not-allowed !important;
        opacity: 0.6;
        pointer-events: none;
    }

    /* Column 2: Enhanced Main Content */
    .exam-main-content {
        background: white;
        border-radius: var(--tcf-radius-lg);
        box-shadow: var(--tcf-shadow);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .main-content-scrollable {
        height: 100%;
        overflow-y: auto;
        padding: 32px !important;
    }

    /* Enhanced Content Scrollbar */
    .main-content-scrollable::-webkit-scrollbar {
        width: 12px;
    }

    .main-content-scrollable::-webkit-scrollbar-track {
        background: #f8f9fa;
        border-radius: 6px;
    }

    .main-content-scrollable::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #adb5bd 0%, #868e96 100%);
        border-radius: 6px;
        border: 2px solid #f8f9fa;
    }

    .main-content-scrollable::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(180deg, #868e96 0%, #6c757d 100%);
    }

    /* Column 3: Enhanced Right Sidebar */
    .exam-sidebar {
        width: 100% !important;
        background: white;
        border-radius: var(--tcf-radius-lg);
        box-shadow: var(--tcf-shadow);
        overflow: hidden;
    }

    .exam-sidebar .card {
        height: 100%;
        border: none !important;
        background: transparent !important;
    }

    .exam-sidebar .card-header {
        background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
        padding: 20px;
        border: none;
        border-radius: var(--tcf-radius-lg) var(--tcf-radius-lg) 0 0;
    }

    /* Enhanced User Avatar */
    .user-photo {
        width: 80px;
        height: 80px;
        margin: 0 auto;
        background: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }

    .user-photo i {
        color: #6366f1 !important;
        font-size: 40px !important;
    }

    /* Enhanced Student Info */
    .student-info {
        padding: 20px;
    }

    .info-row {
        display: flex;
        justify-content: space-between;
        padding: 12px;
        margin-bottom: 8px;
        background: var(--tcf-light);
        border-radius: var(--tcf-radius);
        transition: var(--tcf-transition);
    }

    .info-row:hover {
        background: #e9ecef;
        transform: translateX(4px);
    }

    .info-label {
        font-weight: 600;
        color: var(--tcf-secondary);
        font-size: 14px;
    }

    .info-row span:not(.info-label) {
        font-weight: 500;
        color: var(--tcf-dark);
        font-size: 14px;
    }

    /* Enhanced Timer Section */
    .timer-section {
        padding: 20px;
        background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
        border-radius: var(--tcf-radius-lg);
        margin: 20px;
    }

    .countdown-timer {
        font-size: 48px !important;
        font-weight: 700;
        text-align: center;
        color: var(--tcf-dark);
        font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
        margin-bottom: 12px;
    }

    /* Timer Warning States */
    .countdown-timer.warning {
        color: var(--tcf-warning) !important;
        animation: blink 1s infinite;
    }

    .countdown-timer.danger {
        color: var(--tcf-danger) !important;
        animation: blink 0.5s infinite;
    }

    @keyframes blink {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.6; }
    }

    /* Timer Progress Bar Enhancement */
    .timer-section .progress {
        height: 10px !important;
        background: rgba(255, 255, 255, 0.5) !important;
        border-radius: 5px;
        overflow: hidden;
    }

    #timer-progress {
        background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%) !important;
        transition: width 1s linear !important;
    }

    #timer-progress.warning {
        background: linear-gradient(90deg, var(--tcf-warning) 0%, #f59e0b 100%) !important;
    }

    #timer-progress.danger {
        background: linear-gradient(90deg, var(--tcf-danger) 0%, #b91c1c 100%) !important;
    }
}

/* ========================================
   Medium Desktop Layout (1024px - 1199px)
   ======================================== */
@media (min-width: 1024px) and (max-width: 1199px) {
    .tcf-exam-ce #tcf-test-screen .exam-layout,
    .tcf-exam-co #tcf-test-screen .exam-layout {
        display: grid !important;
        grid-template-columns: 180px 1fr 280px;
        gap: 20px;
        padding: 16px;
    }

    .question-nav-grid .question-nav-btn {
        height: 40px !important;
        font-size: 14px;
    }

    .countdown-timer {
        font-size: 40px !important;
    }

    .user-photo {
        width: 60px;
        height: 60px;
    }

    .user-photo i {
        font-size: 32px !important;
    }
}

/* ========================================
   Small Desktop Layout (992px - 1023px)
   ======================================== */
@media (min-width: 992px) and (max-width: 1023px) {
    .tcf-exam-ce #tcf-test-screen .exam-layout,
    .tcf-exam-co #tcf-test-screen .exam-layout {
        display: grid !important;
        grid-template-columns: 160px 1fr 260px;
        gap: 16px;
        padding: 12px;
    }

    .question-nav-grid .question-nav-btn {
        height: 38px !important;
        font-size: 13px;
    }

    .question-nav-grid .question-nav-btn.answered::after {
        content: "✓";
        right: 8px;
        font-size: 14px;
    }

    .countdown-timer {
        font-size: 36px !important;
    }

    .main-content-scrollable {
        padding: 24px !important;
    }
}

/* ========================================
   Enhanced Question Content Styling
   ======================================== */
.question-content {
    margin-bottom: 32px;
}

.question-text {
    font-size: 18px;
    line-height: 1.8;
    color: var(--tcf-dark);
    margin-bottom: 24px;
    padding: 24px;
    background: var(--tcf-light);
    border-radius: var(--tcf-radius-lg);
    border-left: 4px solid var(--tcf-primary);
}

/* Reading Text Enhancement for CE */
.reading-text-card {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border: 1px solid var(--tcf-border);
    border-radius: var(--tcf-radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.reading-text-content {
    /* Default font size - will be dynamically adjusted by JavaScript */
    font-size: 16px;
    line-height: 1.8;
    color: #374151;
    /* Smooth transition for dynamic font size changes */
    transition: font-size 0.3s ease, line-height 0.3s ease;
}

/* Ensure paragraphs and text elements inherit the dynamic sizing */
.reading-text-content p,
.reading-text-content div:not(.tcf-watermark) {
    font-size: inherit;
    line-height: inherit;
    margin-bottom: 1em;
}

.reading-text-content p:last-child {
    margin-bottom: 0;
}

/* ========================================
   Enhanced Choice Items
   ======================================== */
.choice-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    margin-bottom: 12px;
    background: white;
    border: 2px solid var(--tcf-border);
    border-radius: var(--tcf-radius);
    cursor: pointer;
    transition: var(--tcf-transition);
    position: relative;
    overflow: hidden;
}

.choice-item:hover {
    border-color: var(--tcf-primary);
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%);
    transform: translateX(8px);
    box-shadow: var(--tcf-shadow-hover);
}

.choice-item input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.choice-item label {
    cursor: pointer;
    font-size: 16px;
    line-height: 1.6;
    color: var(--tcf-dark);
    margin: 0;
    flex: 1;
}

.choice-item.selected {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: var(--tcf-primary);
    box-shadow: 0 4px 6px rgba(0, 86, 210, 0.15);
}

.choice-item.selected::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--tcf-primary);
}

/* Choice Letter Badge */
.choice-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--tcf-light);
    border-radius: 50%;
    font-weight: 700;
    color: var(--tcf-secondary);
    margin-right: 12px;
    flex-shrink: 0;
    transition: var(--tcf-transition);
}

.choice-item:hover .choice-letter,
.choice-item.selected .choice-letter {
    background: var(--tcf-primary);
    color: white;
}

/* ========================================
   Enhanced Navigation Buttons
   ======================================== */
.btn {
    padding: 12px 24px;
    font-weight: 600;
    border-radius: var(--tcf-radius);
    transition: var(--tcf-transition);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--tcf-shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--tcf-shadow-hover);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--tcf-primary) 0%, var(--tcf-primary-hover) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--tcf-primary-hover) 0%, #003d9d 100%);
}

.btn-outline-secondary {
    background: white;
    color: var(--tcf-secondary);
    border: 2px solid var(--tcf-border);
}

.btn-outline-secondary:hover {
    background: var(--tcf-light);
    border-color: var(--tcf-secondary);
    color: var(--tcf-dark);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Submit Button Special Style */
.btn-success {
    background: linear-gradient(135deg, var(--tcf-success) 0%, #22c55e 100%);
    color: white;
    font-size: 16px;
    padding: 14px 32px;
}

.btn-success:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

/* ========================================
   Enhanced Audio Timer for CO Tests
   ======================================== */
.audio-timer {
    background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
    padding: 16px;
    border-radius: var(--tcf-radius-lg);
    text-align: center;
    margin-bottom: 24px;
    display: none;
    box-shadow: var(--tcf-shadow);
    border: 1px solid #fbbf24;
}

.audio-timer.active {
    display: block;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.audio-timer i {
    font-size: 24px;
    color: #f59e0b;
    margin-right: 12px;
}

#audio-timer-display {
    font-size: 24px;
    font-weight: 700;
    color: var(--tcf-dark);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

/* ========================================
   Focus States and Accessibility
   ======================================== */
*:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 86, 210, 0.25);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--tcf-primary);
    outline-offset: 2px;
}

/* Skip to main content link for screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.sr-only:focus {
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--tcf-primary);
    color: white;
    padding: 12px 24px;
    z-index: 10000;
    width: auto;
    height: auto;
    clip: auto;
    overflow: visible;
    white-space: normal;
    border-radius: var(--tcf-radius);
    box-shadow: var(--tcf-shadow-hover);
}

/* ========================================
   Reduce Visual Distractions
   ======================================== */
/* Hide unnecessary decorative elements during test */
.tcf-exam-ce #tcf-test-screen *:not(button):not(a)::selection,
.tcf-exam-co #tcf-test-screen *:not(button):not(a)::selection {
    background: rgba(0, 86, 210, 0.2);
}

/* Minimize animations during test */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Clean, focused test environment */
#tcf-test-screen {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    min-height: 100vh;
}

/* Remove any floating elements that might distract */
.tcf-exam-ce .floating-help,
.tcf-exam-co .floating-help,
.tcf-exam-ce .chat-widget,
.tcf-exam-co .chat-widget {
    display: none !important;
}

/* ========================================
   Loading States
   ======================================== */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--tcf-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Responsive Typography
   ======================================== */
@media (min-width: 1200px) {
    .question-text { font-size: 19px; }
    .choice-item label { font-size: 17px; }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .question-text { font-size: 17px; }
    .choice-item label { font-size: 15px; }
}

/* ========================================
   Mobile Responsive - Hide Left Sidebar
   ======================================== */
@media (max-width: 991px) {
    /* IMPORTANT: Hide left sidebar completely on mobile/tablet */
    .tcf-exam-ce #tcf-test-screen .exam-left-sidebar,
    .tcf-exam-co #tcf-test-screen .exam-left-sidebar,
    .tcf-exam-ce .exam-left-sidebar,
    .tcf-exam-co .exam-left-sidebar,
    .exam-left-sidebar {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
    }

    /* Ensure main content takes full width on mobile */
    .tcf-exam-ce #tcf-test-screen .exam-layout,
    .tcf-exam-co #tcf-test-screen .exam-layout {
        grid-template-columns: 1fr !important;
        display: block !important;
    }

    .tcf-exam-ce .exam-main-content,
    .tcf-exam-co .exam-main-content {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Tablet specific - ensure sidebar is hidden */
@media (max-width: 1023px) {
    .tcf-exam-ce .exam-left-sidebar,
    .tcf-exam-co .exam-left-sidebar {
        display: none !important;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .exam-left-sidebar,
    .exam-sidebar,
    .btn,
    .bottom-navigation,
    .mobile-sidebar-toggle {
        display: none !important;
    }

    .exam-main-content {
        width: 100% !important;
        box-shadow: none !important;
    }

    .choice-item {
        page-break-inside: avoid;
    }
}