/* AcePath Quiz Styles based on AIOC example */
body.quiz-body {
    background-color: #c5d1d9;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh; /* Use full viewport height */
    height: 100dvh; /* Dynamic viewport height — fixes iOS Safari toolbar offset */
    font-size: 16px;
    line-height: 1.6;
    overflow: hidden; /* Prevent scrolling on the body */
    /* Prevent iOS elastic over-scroll from bypassing overflow:hidden */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

/* AcePath Watermark - Clean Professional Version */
.acepath-watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 20rem;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.08);
    z-index: 1;
    pointer-events: none;
    user-select: none;
    font-family: 'Arial', sans-serif;
    letter-spacing: 25px;
    white-space: nowrap;
}

/* Multiple watermarks for better coverage */
.acepath-watermark::before {
    content: 'acepath.com.au';
    position: absolute;
    top: -1000px;
    left: -1200px;
    opacity: 0.8;
    font-size: 0.5em;
    color: rgba(0, 0, 0, 0.12);
}

.acepath-watermark::after {
    content: 'acepath.com.au';
    position: absolute;
    top: 1000px;
    left: 1200px;
    opacity: 0.8;
    font-size: 0.5em;
    color: rgba(0, 0, 0, 0.12);
}

/* Responsive watermark sizing */
@media (max-width: 768px) {
    .acepath-watermark {
        font-size: 18rem;
        letter-spacing: 20px;
    }
    
    .acepath-watermark::before,
    .acepath-watermark::after {
        display: none; /* Hide additional watermarks on mobile */
    }
}

@media (max-width: 480px) {
    .acepath-watermark {
        font-size: 12rem;
        letter-spacing: 15px;
    }
}

.quiz-container {
    background-color: white;
    max-width: 1200px; /* Increased from 900px to 1200px for wider layout */
    height: 100vh; /* Use full viewport height */
    height: 100dvh; /* Dynamic viewport height — fixes iOS Safari toolbar offset */
    margin: 0 auto;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent scrolling on the container itself */
    overscroll-behavior: none;
}

.timer {
    background-color: #343a40;
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    display: inline-block;
    width: max-content;
    justify-self: start;
}

.timer-circle {
    background-color: #343a40;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-right: 5px;
}

.timer .timer-unit-label {
    color: #f8f9fa;
    opacity: 0.92;
    font-weight: 600;
}

.header {
    padding: 15px 30px;
    border-bottom: 1px solid #e9ecef;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: linear-gradient(to bottom, #f8f9fa, #f1f3f5);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0; /* Prevent the header from being compressed on small viewports */
}

.logo {
    height: 30px;
}

.brand-logo {
    justify-self: end;
}

.question-number {
    font-weight: 500;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    justify-self: center !important;
}

.quiz-content {
    display: flex;
    flex: 1; /* Take all available space */
    position: relative; /* Added for absolute positioning of the vertical divider */
    overflow: hidden; /* Prevent scrolling on the content container itself */
}

/* Hide divider line on results page - Multiple selectors for maximum coverage */
.quiz-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%; /* Position exactly in the middle */
    height: 100%;
    width: 2px;
    transform: translateX(-50%); /* Center it perfectly */
    background: linear-gradient(to bottom, rgba(0,0,0,0.03), rgba(0,0,0,0.08), rgba(0,0,0,0.03));
    box-shadow: 0 0 5px rgba(0,0,0,0.07);
    z-index: 1; /* Ensure it's above the content */
}

/* Override: Hide divider specifically on results page - Updated */
.quiz-content:has(.results-container)::after,
.results-page .quiz-content::after,
body:has(.results-container) .quiz-content::after {
    display: none !important;
    content: none !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    background: none !important;
}

/* Merge question and answer areas on results pages - Cache bust v2 */
.results-page .quiz-content,
.results-container .quiz-content,
div:has(.results-container) .quiz-content {
    display: block !important;
}

.results-page .question-area,
.results-container .question-area,
div:has(.results-container) .question-area {
    flex: none !important;
    width: 100% !important;
    padding: 0 !important;
    max-width: none !important;
}

.results-page .answers-area,
.results-container .answers-area, 
div:has(.results-container) .answers-area {
    display: none !important;
}

.question-area {
    flex: 1; /* Equal flex distribution */
    padding: 30px;
    position: relative;
    overflow-y: auto; /* Enable vertical scrolling */
    max-height: calc(100vh - 150px); /* Account for header and nav buttons */
}

.answers-area {
    flex: 1; /* Equal flex distribution */
    padding: 30px;
    overflow-y: auto; /* Enable vertical scrolling */
    max-height: calc(100vh - 150px); /* Account for header and nav buttons */
}

/* Animated hint for grid icon */
@keyframes gridPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.grid-icon {
    display: inline-grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 3px;
    width: 24px;
    height: 24px;
    margin-left: 12px;
    vertical-align: middle;
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
    transition: all 0.2s ease;
    animation: gridPulse 2s infinite;
}

.grid-icon:hover {
    background-color: rgba(0, 31, 77, 0.1);
    animation: none;
}

.grid-icon span {
    display: block;
    background-color: #001f4d;
    width: 5px;
    height: 5px;
    border-radius: 1px;
    transition: all 0.2s;
}

.grid-icon:hover span {
    background-color: #0056b3;
}

.question-number {
    display: flex;
    align-items: center;
}

.math-symbol {
    font-weight: bold;
    margin: 0 5px;
}

.radio-option {
    margin: 18px 0;
    padding: 10px 15px;
    border-radius: 8px;
    transition: background-color 0.2s;
    position: relative;
    display: flex;
    align-items: center;
}

.radio-option:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Remove the ::after pseudo-element since we'll use a different approach */
.form-check-input {
    width: 22px;
    height: 22px;
    margin-right: 0;
}

/* Style for option label (A, B, C, D) */
.option-letter {
    display: inline-block;
    margin: 0 10px;
    font-weight: 600;
    font-size: 1.1rem;
    color: #001f4d;
    vertical-align: middle;
    width: 20px;
}

.form-check-label {
    font-size: 1.05rem;
    padding: 2px 0;
    vertical-align: middle;
}

/* 
 * Navigation footer structure:
 * - Left side: Back button
 * - Center: Flag button
 * - Right side: Submit button (last question only) and Continue button
 */
.nav-buttons {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 10px); /* Slight reduction to avoid horizontal scrollbar */
    max-width: 1200px; /* Match quiz container max-width */
    display: flex;
    justify-content: space-between;
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
    padding: 15px 30px; /* Increased padding for better spacing in wider layout */
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* Container for Submit + Next buttons on right side */
.nav-right-buttons {
    display: flex;
    gap: 10px;
}

.nav-btn {
    min-width: 120px;
    padding: 10px 20px;
    font-size: 1rem;
}

.back-btn {
    background-color: #001f4d;
    color: white;
}

.next-btn {
    background-color: #001f4d;
    color: white;
}

.submit-btn {
    background-color: #28a745;
    color: white;
}

.submit-btn:hover {
    background-color: #218838;
    color: white;
}

.flag-btn {
    background-color: #f8f9fa;
    color: #333;
    transition: background-color 0.2s, color 0.2s;
}

.flag-btn.active {
    background-color: #dc3545;
    color: white;
}

.flag-btn:hover {
    background-color: #e9ecef;
}

.flag-btn.active:hover {
    background-color: #c82333;
}

.navigation-tab {
    position: absolute;
    right: 50%;
    bottom: -25px;
    transform: translateX(50%);
    width: 40px;
    height: 40px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.navigation-tab:hover {
    background-color: #f8f9fa;
    transform: translateX(50%) translateY(-3px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.15);
}

/* Submit button now in footer */

/* Style for when a question is not being displayed */
.question-card {
    display: none;
}

/* Question navigation counter */
.question-counter {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    font-size: 0.9rem;
    color: #6c757d;
}

/* Question Navigation Button styles */
.nav-btn {
    transition: background-color 0.2s, transform 0.1s;
}

.nav-btn:hover:not(.disabled) {
    transform: translateY(-2px);
}

.nav-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Dashboard button (shown in review mode) */
.dashboard-btn {
    background-color: #6c757d;
    color: white;
}

.dashboard-btn:hover {
    background-color: #5a6268;
    color: white;
}

/* Review button */
.review-btn {
    background-color: #28a745;
    color: white;
}

.review-btn:hover {
    background-color: #218838;
    color: white;
}

/* Question grid for review */
.question-grid-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border: 1px solid #eee;
    box-shadow: 0 0 25px rgba(0,0,0,0.2);
    padding: 30px 40px;
    z-index: 1000;
    width: 80%;
    max-width: 900px;
    margin: 0 auto;
    border-radius: 12px;
    max-height: 90vh;
    overflow-y: auto;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    backdrop-filter: blur(5px);
}

.question-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.question-grid-header h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #001f4d;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 15px;
    margin-bottom: 25px;
    max-width: 850px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 12px;
    }
    
    .question-grid-container {
        width: 90%;
        padding: 20px;
    }
    
    .grid-item {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .question-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    .question-grid-container {
        width: 95%;
        padding: 15px;
    }
    
    .legend {
        flex-direction: column;
        gap: 5px;
    }
    
    .legend-item {
        font-size: 0.85rem;
    }
    
    .grid-item {
        width: 40px;
        height: 40px;
    }
}

.grid-item {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    background-color: white;
    transition: all 0.2s;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.grid-item:hover {
    background-color: #f0f7ff;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,31,77,0.1);
}

.grid-item.current {
    border: 2px solid #007bff;
    color: #007bff;
    font-weight: 700;
    background-color: #e6f2ff;
}

.grid-item.answered {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.grid-item.flagged {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.grid-item.answered.flagged {
    background: linear-gradient(135deg, #d4edda 50%, #f8d7da 50%);
    position: relative;
    overflow: hidden;
}

.grid-item.answered.flagged::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background-color: #dc3545;
    border-radius: 50%;
}

.question-grid-footer {
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 10px;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    padding: 5px 10px;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.grid-item-answered, .grid-item-flagged, .grid-item-current {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    margin-right: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.grid-item-answered {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.grid-item-flagged {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

.grid-item-current {
    background-color: #e6f2ff;
    border: 2px solid #007bff;
}

.close-grid-btn {
    transition: all 0.2s;
    padding: 5px 10px;
    font-size: 0.9rem;
}

.close-grid-btn:hover {
    background-color: #e9ecef;
}

/* Reading passage styles */
.reading-passage {
    background-color: #f9f9f9;
    padding: 25px 30px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.65;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
}

.reading-passage p {
    margin-bottom: 1rem;
}

.reading-passage h1, .reading-passage h2, .reading-passage h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.reading-passage ul, .reading-passage ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.reading-passage li {
    margin-bottom: 0.5rem;
}

.reading-passage img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
}

.reading-passage blockquote {
    border-left: 4px solid #dee2e6;
    padding-left: 1rem;
    font-style: italic;
    margin-left: 0;
    margin-right: 0;
}

/* Question specific styles */
.question-wrapper {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.question-title {
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 1.4rem;
    color: #001f4d;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.question-text {
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.65;
}

.question-content {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Flagged question style */
.flagged {
    position: relative;
}

.flagged:after {
    content: '🚩';
    position: absolute;
    top: 0;
    right: 0;
    font-size: 20px;
}

/* Responsive styles */
@media (max-width: 992px) {
    .quiz-container {
        max-width: 95%;
    }
    
    .reading-passage {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .quiz-content {
        flex-direction: column;
        height: auto;
    }
    
    .question-area, .answers-area {
        flex: 0 0 auto;
        padding: 20px;
        max-height: calc(50vh - 100px); /* Split screen height between two sections */
    }
    
    .question-area {
        border-bottom: 1px solid #eee;
    }

    /* Hide vertical divider and replace with horizontal one on small screens */
    .quiz-content::after {
        width: 100%;
        height: 2px;
        top: auto;
        bottom: 50%;
        right: auto;
        left: 0;
        background: linear-gradient(to right, rgba(0,0,0,0.03), rgba(0,0,0,0.08), rgba(0,0,0,0.03));
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    .nav-buttons {
        position: fixed;
        bottom: 0;
        width: 100%;
        padding: 10px 15px;
    }
}

/* Passage and Question content containers */
.passage-content-container.active,
.question-content-container.active {
    display: block;
}

/* Improve spacing and layout */
.quiz-content {
    padding-bottom: 0; /* Remove padding as we're using fixed height */
}

.question-area, .answers-area {
    padding-bottom: 30px; /* Add more padding at the bottom */
}

/* Style answer options better for wider layout */
.options {
    margin-top: 25px;
    background-color: #f9f9f9;
    border-radius: 10px;
    padding: 15px 20px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}

/* Style passage sections better */
.passage-content-container {
    padding: 15px 0;
}

.passage-content-container h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #001f4d;
}

/* Passage toggle button */
.passage-toggle {
    padding: 6px 12px;
    font-size: 0.9rem;
    border-radius: 20px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.passage-toggle:hover {
    background-color: #e9ecef;
}

/* Style question cards */
.question-card {
    margin-bottom: 20px;
}

.question-card .question-title {
    color: #001f4d;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

/* Grid overlay styles */
.question-grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(3px);
    z-index: 999;
    transition: opacity 0.3s ease;
}

/* Grid progress indicator */
.grid-progress {
    font-size: 0.9rem;
    color: #6c757d;
    margin: 5px 0 0 0;
}

#gridProgress #answeredCount {
    font-weight: 600;
    color: #28a745;
}

#gridProgress #totalCount {
    font-weight: 600;
    color: #001f4d;
}

/* Keyboard shortcuts display */
.keyboard-shortcuts {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #6c757d;
    text-align: center;
}

.keyboard-shortcuts kbd {
    display: inline-block;
    background-color: #fff;
    border: 1px solid #bbb;
    border-bottom: 2px solid #999;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    padding: 2px 8px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #333;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    line-height: 1.4;
    min-width: 22px;
    text-align: center;
}

.next-btn.submit-mode {
    background-color: #28a745;
    color: white;
    min-width: 180px;
    font-weight: 500;
}

.next-btn.submit-mode:hover {
    background-color: #218838;
}

/* Modern confirmation dialog styling */
.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}

.custom-dialog {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    padding: 0;
    width: 90%;
    max-width: 500px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
}

.custom-dialog-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.custom-dialog-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #001f4d;
    margin: 0;
}

.custom-dialog-close {
    position: absolute;
    right: 20px;
    top: 20px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.custom-dialog-close:hover {
    background-color: #f0f0f0;
    color: #343a40;
}

.custom-dialog-body {
    padding: 25px 25px;
    font-size: 1.1rem;
    color: #495057;
    line-height: 1.6;
}

.custom-dialog-progress {
    margin: 20px 0;
    background-color: #f0f0f0;
    height: 10px;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, #28a745, #20c997);
    transition: width 0.5s ease;
}

.dialog-stats {
    display: flex;
    justify-content: space-between;
    margin: 15px 0 25px;
}

.stat-item {
    text-align: center;
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #001f4d;
    display: block;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #6c757d;
}

.flagged-stat .stat-value {
    color: #dc3545;
}

.custom-dialog-footer {
    display: flex;
    justify-content: flex-end;
    padding: 15px 25px 25px;
    gap: 15px;
}

.dialog-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.dialog-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.btn-cancel {
    background-color: #f8f9fa;
    color: #343a40;
    border: 1px solid #dee2e6;
}

.btn-submit {
    background-color: #28a745;
    color: white;
}
