/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Main app container */
.exam-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header styles */
.exam-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    text-align: center;
}

.exam-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.exam-subtitle {
    font-size: 1.2rem;
    color: #7f8c8d;
    font-weight: 300;
}

/* Main content area */
.exam-main {
    flex: 1;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    width: 100%;
}

/* Footer styles */
.exam-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.footer-links a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #2980b9;
}

/* Welcome container */
.welcome-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.welcome-header h1 {
    font-size: 3rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.exam-description {
    font-size: 1.2rem;
    color: #7f8c8d;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.exam-instructions, .exam-stats {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem 0;
    text-align: left;
}

.exam-instructions h3, .exam-stats h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.exam-instructions ul {
    list-style: none;
    padding-left: 0;
}

.exam-instructions li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.exam-instructions li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #27ae60;
    font-weight: bold;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.stat-item {
    text-align: center;
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: #3498db;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Button styles */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, #21618c);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

.btn-secondary:hover {
    background: #d5dbdb;
    transform: translateY(-1px);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.2rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Question styles */
.question-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px 15px 0 0;
    padding: 1.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.question-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.question-number {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
}

.timer-display {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.timer-warning {
    background: rgba(241, 196, 15, 0.2);
    color: #f39c12;
    animation: pulse 1s infinite;
}

.timer-danger {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Question content */
.question-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.question-text {
    font-size: 1.3rem;
    line-height: 1.8;
    color: #2c3e50;
    margin-bottom: 2rem;
    white-space: pre-line;
}

.options-container {
    display: grid;
    gap: 1rem;
}

.option {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.option:hover {
    background: #e9ecef;
    border-color: #3498db;
}

.option.selected {
    background: rgba(52, 152, 219, 0.1);
    border-color: #3498db;
}

.option input[type="radio"] {
    margin-right: 1rem;
    transform: scale(1.2);
    accent-color: #3498db;
}

.option label {
    flex: 1;
    font-size: 1.1rem;
    cursor: pointer;
    user-select: none;
}

/* Question footer */
.question-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0 0 15px 15px;
    padding: 1.5rem 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.question-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.question-nav-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #bdc3c7;
    background: white;
    color: #7f8c8d;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.question-nav-btn:hover {
    border-color: #3498db;
    color: #3498db;
}

.question-nav-btn.active {
    border-color: #3498db;
    background: #3498db;
    color: white;
}

.question-nav-btn.answered {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
}

/* Results container */
.results-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.results-header {
    text-align: center;
    margin-bottom: 3rem;
}

.results-header h1 {
    font-size: 3rem;
    color: #2c3e50;
    margin-bottom: 2rem;
}

.results-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-bottom: 2rem;
    align-items: start;
}

.score-card {
    text-align: center;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.score-card.pass {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.score-card.fail {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.score-percentage {
    font-size: 4rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.score-grade {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.score-details {
    font-size: 1.2rem;
    opacity: 0.9;
}

.exam-details {
    display: grid;
    gap: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.detail-item .label {
    font-weight: 600;
    color: #7f8c8d;
}

.detail-item .value {
    font-weight: 600;
    color: #2c3e50;
}

.detail-item .value.pass {
    color: #27ae60;
}

.detail-item .value.fail {
    color: #e74c3c;
}

.grade-description {
    font-size: 1.3rem;
    color: #7f8c8d;
    font-style: italic;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

/* Question review */
.question-review {
    margin-top: 3rem;
    border-top: 2px solid #ecf0f1;
    padding-top: 2rem;
}

.question-review-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #bdc3c7;
}

.question-review-item.correct {
    border-left-color: #27ae60;
    background: rgba(39, 174, 96, 0.05);
}

.question-review-item.incorrect {
    border-left-color: #e74c3c;
    background: rgba(231, 76, 60, 0.05);
}

.review-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.review-question-number {
    font-weight: 600;
    color: #2c3e50;
}

.result-indicator {
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 600;
}

.result-indicator.correct {
    background: rgba(39, 174, 96, 0.2);
    color: #27ae60;
}

.result-indicator.incorrect {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.review-question-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.review-answers {
    display: grid;
    gap: 0.8rem;
}

.review-answer {
    padding: 0.8rem;
    border-radius: 6px;
    font-weight: 500;
}

.review-answer.user-answer.correct {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
}

.review-answer.user-answer.incorrect {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.review-answer.correct-answer {
    background: rgba(39, 174, 96, 0.2);
    color: #27ae60;
}

.review-explanation {
    background: #e8f4f8;
    padding: 1rem;
    border-radius: 6px;
    border-left: 3px solid #3498db;
    margin-top: 1rem;
}

.review-explanation strong {
    color: #2c3e50;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .exam-title {
        font-size: 2rem;
    }
    
    .exam-main {
        margin: 1rem auto;
        padding: 0 1rem;
    }
    
    .welcome-container,
    .results-container {
        padding: 2rem 1.5rem;
    }
    
    .welcome-header h1,
    .results-header h1 {
        font-size: 2rem;
    }
    
    .results-summary {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .question-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .question-nav {
        order: -1;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 1rem;
    }
    
    .results-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .question-info {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .question-nav-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .option {
        padding: 0.8rem;
    }
    
    .option label {
        font-size: 1rem;
    }
    
    /* Mobile-specific button styles */
    .btn {
        min-height: 48px; /* Better touch target */
        font-size: 1.1rem;
        padding: 1rem 2rem;
    }
    
    /* Finish exam button specific styling */
    #next-btn {
        background: linear-gradient(135deg, #27ae60, #2ecc71) !important;
        color: white !important;
        font-weight: bold !important;
        box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3) !important;
        border: 2px solid #27ae60 !important;
        animation: pulse-finish 2s infinite;
    }
    
    @keyframes pulse-finish {
        0% {
            box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
        }
        50% {
            box-shadow: 0 6px 12px rgba(39, 174, 96, 0.5);
        }
        100% {
            box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
        }
    }
    
    /* Footer finish button styling */
    #footer-finish-btn {
        background: #e74c3c !important;
        color: white !important;
        padding: 0.8rem 1.5rem !important;
        border-radius: 8px !important;
        font-weight: bold !important;
        text-decoration: none !important;
        display: inline-block !important;
        margin: 0.5rem !important;
        box-shadow: 0 3px 6px rgba(231, 76, 60, 0.3) !important;
        transition: all 0.3s ease !important;
    }
    
    #footer-finish-btn:hover {
        background: #c0392b !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 5px 10px rgba(231, 76, 60, 0.4) !important;
    }
}

/* Print styles */
@media print {
    .exam-header,
    .exam-footer,
    .question-footer,
    .results-actions {
        display: none;
    }
    
    .exam-main {
        margin: 0;
        padding: 0;
    }
    
    .question-content,
    .results-container {
        box-shadow: none;
        background: white;
    }
}