/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Utility Classes */
.text-success { color: #27ae60; }
.text-danger { color: #e74c3c; }
.text-warning { color: #f39c12; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

/* Container */
.container {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

/* Typography */
h1 {
    text-align: center;
    color: #1e3c72;
    margin-bottom: 30px;
    font-size: 2.5em;
}

h2 {
    color: #1e3c72;
    margin-bottom: 15px;
}

h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

/* Exam Setup */
.exam-setup {
    display: block;
}

.exam-info {
    background: #f0f4ff;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    border-left: 5px solid #2a5298;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.info-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.info-item .value {
    font-size: 24px;
    font-weight: bold;
    color: #2a5298;
}

.info-item .label {
    color: #666;
    margin-top: 5px;
}

/* Configuration */
.exam-config {
    margin-bottom: 30px;
}

.config-group {
    margin-bottom: 20px;
}

.config-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #333;
}

.config-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.category-selection {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.category-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.category-btn:hover {
    border-color: #2a5298;
    background: #f0f4ff;
}

.category-btn.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.category-count {
    font-size: 12px;
    opacity: 0.8;
    margin-left: 5px;
}

.config-btn {
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s;
}

.config-btn:hover {
    border-color: #2a5298;
    background: #f0f4ff;
}

.config-btn.active {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

.start-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 30px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
    margin: 30px auto 0;
}

.start-btn:hover {
    background: #229954;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

/* Exam Summary */
.exam-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f0f4ff;
    border-radius: 8px;
    display: none;
}

/* Exam Container */
.exam-container {
    display: none;
}

/* Progress Section */
.progress-section {
    margin-bottom: 30px;
}

.overall-progress {
    background: #ecf0f1;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.overall-progress-bar {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

.category-progress {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.category-progress-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
}

.category-progress-bar {
    background: #ecf0f1;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 5px;
}

.category-progress-fill {
    background: #3498db;
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

/* Question Header */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.question-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.question-number {
    background: #2a5298;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
}

.category-badge {
    background: #e74c3c;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.timer {
    background: #f39c12;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
}

/* Question and Options */
.question {
    font-size: 20px;
    color: #2c3e50;
    margin-bottom: 30px;
    line-height: 1.5;
}

.options {
    list-style: none;
}

.option {
    background: #f8f9fa;
    margin: 15px 0;
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    position: relative;
}

.option:hover {
    background: #e8ecff;
    border-color: #2a5298;
}

.option.selected {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

.option input[type="radio"] {
    display: none;
}

.option-label {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
}

.option-circle {
    width: 20px;
    height: 20px;
    border: 2px solid #bdc3c7;
    border-radius: 50%;
    margin-right: 15px;
    position: relative;
    flex-shrink: 0;
}

.option.selected .option-circle {
    border-color: white;
}

.option.selected .option-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

/* Visual Feedback */
.option.correct {
    background: #d4edda !important;
    border-color: #28a745 !important;
    animation: correctPulse 0.5s ease-out;
}

.option.incorrect {
    background: #f8d7da !important;
    border-color: #dc3545 !important;
    animation: shake 0.5s ease-out;
}

.option.correct::after,
.option.incorrect::after {
    position: absolute;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
}

.option.correct::after {
    content: '✓';
    color: #28a745;
}

.option.incorrect::after {
    content: '✗';
    color: #dc3545;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.option.show-correct {
    background: #d4edda !important;
    border-color: #28a745 !important;
}

.feedback-mode .option {
    pointer-events: none;
}

/* Feedback Text */
.feedback-text {
    margin-top: 20px;
    padding: 20px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 500;
    display: none;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.feedback-text.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback-text.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-btn {
    padding: 10px 30px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

.prev-btn {
    background: #95a5a6;
    color: white;
}

.prev-btn:hover:not(:disabled) {
    background: #7f8c8d;
}

.next-btn {
    background: #3498db;
    color: white;
}

.next-btn:hover {
    background: #2980b9;
}

.submit-btn {
    background: #27ae60;
    color: white;
}

.submit-btn:hover {
    background: #229954;
}

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

/* Question Navigator */
.question-navigator {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 5px;
}

.question-nav-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 5px;
    font-size: 12px;
    transition: all 0.3s;
}

.question-nav-btn:hover {
    background: #e8ecff;
    border-color: #2a5298;
}

.question-nav-btn.answered {
    background: #27ae60;
    color: white;
    border-color: #27ae60;
}

.question-nav-btn.current {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

/* Results Container */
.results-container {
    display: none;
    text-align: center;
}

.score-circle {
    width: 200px;
    height: 200px;
    margin: 30px auto;
    position: relative;
}

.score-circle svg {
    transform: rotate(-90deg);
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    color: #2c3e50;
}

.result-details {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    margin: 30px 0;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.result-row:last-child {
    border-bottom: none;
}

/* Category Breakdown */
.category-breakdown {
    margin-top: 30px;
    text-align: left;
}

.category-result {
    background: white;
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.category-result .score {
    font-weight: bold;
    color: #27ae60;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

/* Review Section */
.review-section {
    margin-top: 30px;
    text-align: left;
    display: none;
}

.review-info {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.review-question {
    background: #f8f9fa;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    border-left: 4px solid #e0e0e0;
}

.review-question.correct {
    border-left-color: #27ae60;
}

.review-question.incorrect {
    border-left-color: #e74c3c;
}

.review-options {
    list-style: none;
    margin-top: 15px;
}

.review-option {
    padding: 10px;
    margin: 5px 0;
    border-radius: 5px;
    background: white;
    position: relative;
}

.review-option.user-selected {
    background: #ffe5e5;
}

.review-option.user-selected::before {
    content: '✗ Your answer';
    position: absolute;
    right: 10px;
    color: #e74c3c;
    font-size: 12px;
    font-weight: bold;
}

.review-option.correct-answer {
    background: #e5ffe5;
    font-weight: bold;
}

.review-option.correct-answer::after {
    content: '✓ Correct';
    position: absolute;
    right: 10px;
    color: #27ae60;
    font-size: 12px;
    font-weight: bold;
}

.review-option.user-selected.correct-answer::before {
    content: '✓ Your answer (Correct!)';
    color: #27ae60;
}

.explanation-box {
    background: #e8f5e8;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 4px solid #4caf50;
}

.explanation-box strong {
    color: #2e7d32;
    display: block;
    margin-bottom: 5px;
}

.question-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    margin-left: 10px;
}

.status-correct {
    background: #27ae60;
    color: white;
}

.status-incorrect {
    background: #e74c3c;
    color: white;
}

/* Responsive Design */
@media (max-width: 600px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .question-navigator {
        display: none;
    }
    
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .question {
        font-size: 16px;
    }
}