/* ===========================
   QUIZ FINAL DESIGN - Stanford-Binet IQ Test
   Complete, polished quiz interface with attention to detail
   Overrides all conflicting styles
   =========================== */

/* =========================
   CSS RESET & OVERRIDES
   ========================= */

/* Global touch optimizations */
* {
    -webkit-tap-highlight-color: transparent;
}

body {
    touch-action: manipulation; /* Prevent double-tap zoom */
}

/* Remove ALL shadows and animations from mobile-optimized.css */
.quiz-header,
.quiz-header *,
.countdown-timer,
.timer-compact,
.question-card,
.answer-choice,
.submit-btn {
    animation: none !important;
    box-shadow: none !important;
}

/* =========================
   QUIZ LAYOUT STRUCTURE
   ========================= */

.quiz-layout {
    min-height: 100vh;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
}

/* =========================
   HEADER - POLISHED & SPACIOUS
   ========================= */

.quiz-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 56px !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    z-index: 1000 !important;
    padding-top: 8px !important; /* Breathing room from top */
}

.quiz-header-content {
    max-width: 1200px;
    margin: 0 auto;
    height: 48px; /* 56px - 8px padding */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

/* Logo styling */
.quiz-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #1a202c;
    font-weight: 600;
}

.quiz-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #0F4C81 0%, #1E6BA8 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
}

.quiz-logo-text {
    font-size: 16px;
    display: none;
}

/* Progress info container */
.quiz-progress-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Question counter */
.question-counter {
    font-size: 15px;
    font-weight: 600;
    color: #0F4C81;
}

/* =========================
   TIMER - CLEAN & PROFESSIONAL
   ========================= */

.countdown-timer,
.timer-compact {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 14px !important;
    background: #f7fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    font-family: 'SF Mono', Monaco, Consolas, monospace !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #2d3748 !important;
    transition: all 0.2s ease !important;
}

.countdown-timer svg,
.timer-compact svg {
    width: 18px !important;
    height: 18px !important;
    stroke-width: 2 !important;
}

/* Timer states */
.countdown-timer.warning,
.timer-compact.warning {
    background: #fef3c7 !important;
    border-color: #f59e0b !important;
    color: #92400e !important;
}

.countdown-timer.danger,
.timer-compact.danger {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
    /* Subtle pulse without glitches */
    animation: subtle-pulse 2s ease-in-out infinite !important;
}

@keyframes subtle-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Progress bar */
.quiz-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e2e8f0;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0F4C81 0%, #1E6BA8 100%);
    transition: width 0.5s ease-out;
}

/* =========================
   MAIN CONTENT AREA
   ========================= */

.quiz-main {
    flex: 1;
    margin-top: 56px; /* Match header height */
    padding: 20px 16px; /* Reduced from excessive padding */
}

.quiz-container {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

/* Question page wrapper */
.question-page {
    min-height: calc(100vh - 56px - 40px); /* header - footer */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================
   QUESTION CARD
   ========================= */

.question-card {
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05) !important;
    border: 1px solid #e2e8f0 !important;
    width: 100%;
    overflow: visible;
}

.question-form {
    padding: 28px; /* Balanced padding */
}

/* Question content */
.question-content {
    text-align: center;
    margin-bottom: 28px;
}

.question-text {
    font-size: 18px;
    line-height: 1.6;
    color: #1a202c;
    font-weight: 500;
    margin-bottom: 8px;
}

.question-hint {
    font-size: 15px;
    color: #718096;
    margin: 0;
    font-style: italic;
}

.question-image {
    margin-bottom: 20px;
}

.question-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* =========================
   ANSWER CHOICES
   ========================= */

.answers-section {
    margin-bottom: 24px;
}

.answer-choice {
    display: flex !important;
    align-items: center !important;
    padding: 14px 16px !important; /* Optimized padding */
    margin-bottom: 12px !important;
    background: #f7fafc !important;
    border: 2px solid transparent !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-height: 56px !important; /* Good touch target */
    position: relative !important;
    overflow: hidden !important;
}

.answer-choice:last-child {
    margin-bottom: 0 !important;
}

.answer-choice:hover {
    background: #edf2f7 !important;
    transform: translateX(2px) !important; /* Reduced from 4px */
    border-color: #cbd5e0 !important;
}

.answer-choice.selected,
.answer-choice:has(input:checked) {
    background: #0F4C81 !important;
    border-color: #0F4C81 !important;
    color: white !important;
    transform: translateX(3px) !important; /* Reduced from 8px */
}

/* Left accent bar for selected state */
.answer-choice.selected::before,
.answer-choice:has(input:checked)::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: white;
}

/* Hide radio inputs */
.answer-choice input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Answer content layout */
.answer-content {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 14px;
}

/* Letter badge */
.answer-letter {
    width: 32px !important;
    height: 32px !important;
    background: white !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    color: #0F4C81 !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06) !important;
}

.answer-choice.selected .answer-letter,
.answer-choice:has(input:checked) .answer-letter {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    box-shadow: none !important;
}

/* Answer text */
.answer-text {
    flex: 1;
    font-size: 16px;
    line-height: 1.5;
    text-align: left;
    color: #2d3748;
}

.answer-choice.selected .answer-text,
.answer-choice:has(input:checked) .answer-text {
    color: white !important;
}

/* Check indicator */
.answer-indicator {
    margin-left: auto;
    width: 24px;
    height: 24px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.answer-choice.selected .answer-indicator,
.answer-choice:has(input:checked) .answer-indicator {
    opacity: 1 !important;
    transform: scale(1) !important;
}

.answer-indicator svg {
    width: 100%;
    height: 100%;
    color: white;
}

/* =========================
   TEXT INPUT QUESTIONS
   ========================= */

.text-input-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.text-input-label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 12px;
}

.text-input-field {
    width: 100%;
    padding: 14px 16px;
    font-size: 17px; /* Prevent iOS zoom */
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #f7fafc;
    transition: all 0.2s ease;
    text-align: center;
}

.text-input-field:focus {
    border-color: #0F4C81;
    background: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.1);
}

/* =========================
   SUBMIT BUTTON
   ========================= */

.form-actions {
    margin-top: 28px;
    text-align: center;
}

.submit-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 14px 32px !important;
    background: linear-gradient(135deg, #0F4C81 0%, #1E6BA8 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 12px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    min-width: 200px !important;
    height: 52px !important;
    box-shadow: 0 4px 14px rgba(15, 76, 129, 0.25) !important;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(15, 76, 129, 0.35) !important;
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0) !important;
}

.submit-btn:disabled {
    background: #cbd5e0 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 0.7 !important;
}

.submit-btn .btn-text {
    line-height: 1;
}

.submit-btn .btn-icon {
    width: 20px !important;
    height: 20px !important;
    display: block !important; /* Always show icon */
}

/* =========================
   FOOTER
   ========================= */

.quiz-footer {
    background: white;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    margin-top: auto;
}

.quiz-footer-content {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
    font-size: 13px;
    color: #718096;
}

.quiz-footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.quiz-footer-links a {
    color: #718096;
    text-decoration: none;
    transition: color 0.2s ease;
}

.quiz-footer-links a:hover {
    color: #0F4C81;
}

/* =========================
   MOBILE RESPONSIVE
   ========================= */

@media (max-width: 768px) {
    /* Header adjustments */
    .quiz-header {
        height: 48px !important;
        padding-top: 4px !important;
    }
    
    .quiz-header-content {
        height: 44px;
        padding: 0 16px;
    }
    
    .quiz-logo-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .quiz-progress-info {
        gap: 16px;
    }
    
    .question-counter {
        font-size: 14px;
    }
    
    /* Timer adjustments */
    .countdown-timer,
    .timer-compact {
        padding: 4px 10px !important;
        font-size: 14px !important;
        gap: 6px !important;
    }
    
    .countdown-timer svg,
    .timer-compact svg {
        width: 16px !important;
        height: 16px !important;
    }
    
    /* Main content */
    .quiz-main {
        margin-top: 48px;
        padding: 16px 12px;
    }
    
    /* Question card */
    .question-card {
        border-radius: 12px !important;
    }
    
    .question-form {
        padding: 20px 16px; /* Optimized mobile padding */
        padding-bottom: 80px; /* Space for fixed button */
    }
    
    .question-text {
        font-size: 17px;
    }
    
    .question-hint {
        font-size: 14px;
    }
    
    /* Answer choices */
    .answer-choice {
        padding: 12px 14px !important;
        min-height: 52px !important;
        margin-bottom: 10px !important;
    }
    
    .answer-letter {
        width: 28px !important;
        height: 28px !important;
        font-size: 13px !important;
    }
    
    .answer-text {
        font-size: 15px;
    }
    
    .answer-content {
        gap: 12px;
    }
    
    /* Fixed submit button on mobile */
    .form-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 12px 16px;
        margin: 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        z-index: 100;
        border-top: 1px solid #e2e8f0;
    }
    
    .submit-btn {
        width: 100% !important;
        padding: 12px 24px !important;
        font-size: 15px !important;
        height: 48px !important;
        min-width: unset !important;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .quiz-header-content {
        padding: 0 12px;
    }
    
    .quiz-progress-info {
        gap: 12px;
    }
    
    .quiz-main {
        padding: 12px 8px;
    }
    
    .question-form {
        padding: 16px 12px;
        padding-bottom: 80px;
    }
    
    .question-text {
        font-size: 16px;
    }
    
    .answer-choice {
        padding: 12px !important;
    }
    
    .answer-text {
        font-size: 14px;
    }
}

/* Desktop enhancements */
@media (min-width: 769px) {
    .quiz-logo-text {
        display: block;
    }
    
    .quiz-header-content {
        padding: 0 32px;
    }
    
    .question-form {
        padding: 36px;
    }
    
    .answer-choice:hover {
        transform: translateX(6px) !important;
    }
    
    .answer-choice.selected,
    .answer-choice:has(input:checked) {
        transform: translateX(12px) !important;
    }
}

/* =========================
   LOADING & ANIMATIONS
   ========================= */

/* Loading overlay */
#submission-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Time warning toast */
.time-warning-toast {
    position: fixed;
    top: 70px; /* Below header */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1100;
    animation: slideDown 0.3s ease-out;
}

.time-warning-toast.warning {
    border-left: 4px solid #f59e0b;
}

.time-warning-toast.danger {
    border-left: 4px solid #ef4444;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* =========================
   ACCESSIBILITY
   ========================= */

.answer-choice:focus-visible {
    outline: 3px solid #0F4C81;
    outline-offset: 2px;
}

.submit-btn:focus-visible {
    outline: 3px solid white;
    outline-offset: 2px;
}

/* Touch feedback */
.answer-choice.touch-active {
    transform: scale(0.98);
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .answer-choice {
        border-width: 3px;
    }
    
    .answer-choice.selected,
    .answer-choice:has(input:checked) {
        outline: 3px solid #000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =========================
   FINAL OVERRIDES
   ========================= */

/* Ensure our styles take precedence */
.quiz-layout .countdown-timer,
.quiz-layout .timer-compact,
.quiz-layout .question-card,
.quiz-layout .answer-choice,
.quiz-layout .submit-btn {
    /* Use our styles, not mobile-optimized.css */
    all: revert;
}