/* Advanced Exam System Styles */
:root {
    --primary-color: #2271b1;
    --success-color: #00a32a;
    --warning-color: #dba617;
    --danger-color: #d63638;
    --text-color: #1d2327;
    --bg-color: #ffffff;
    --border-color: #c3c4c7;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* Exam List Styles */
.exam-list-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.exam-list-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-color);
    font-size: 2.5em;
}

.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.exam-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.exam-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
}

.exam-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.exam-card h3 {
    margin: 0 0 15px 0;
    font-size: 1.4em;
    color: var(--text-color);
}

.exam-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.exam-meta span {
    background: #f0f0f1;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9em;
    color: var(--text-color);
}

.exam-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.btn-start-exam {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: var(--border-radius);
    font-size: 1em;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    font-weight: 600;
}

.btn-start-exam:hover {
    background: #135e96;
    transform: translateY(-2px);
}

/* Modal Styles */
.exam-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.exam-modal-content {
    background: var(--bg-color);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.exam-modal h3 {
    margin: 0 0 20px 0;
    text-align: center;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1em;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
}

.btn-cancel, .btn-confirm {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1em;
    transition: var(--transition);
}

.btn-cancel {
    background: #f6f7f7;
    color: var(--text-color);
}

.btn-cancel:hover {
    background: #dcdcde;
}

.btn-confirm {
    background: var(--primary-color);
    color: white;
}

.btn-confirm:hover {
    background: #135e96;
}

/* Exam Taking Styles */
.exam-taking-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    position: sticky;
    top: 0;
    z-index: 100;
    border: 2px solid var(--border-color);
}

.exam-header h2 {
    margin: 0;
    color: var(--text-color);
}

.exam-timer {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    background: #f0f6fc;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    border: 2px solid #b8d4f0;
}

.exam-timer.warning {
    color: var(--warning-color);
    background: #fef7e0;
    border-color: #f0d000;
    animation: timerPulse 1s infinite;
}

.exam-timer.critical {
    color: var(--danger-color);
    background: #fcebea;
    border-color: #f56565;
    animation: timerPulse 0.5s infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Question Navigation */
.question-navigation {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.question-navigation.sticky {
    position: fixed;
    top: 100px;
    right: 20px;
    width: 250px;
    z-index: 99;
    max-height: 60vh;
    overflow-y: auto;
}

.question-navigation h4 {
    margin: 0 0 15px 0;
    color: var(--text-color);
    cursor: pointer;
}

.question-navigation h4.collapsed::after {
    content: ' ▼';
}

.question-navigation h4:not(.collapsed)::after {
    content: ' ▲';
}

.question-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 8px;
}

.question-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    transition: var(--transition);
}

.question-nav-item:hover {
    border-color: var(--primary-color);
    background: #f0f6fc;
}

.question-nav-item.answered {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.question-nav-item.current {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.1);
}

/* Question Block Styles */
.question-block {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.question-block:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.question-number {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.question-content {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 20px;
    color: var(--text-color);
}

.question-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 15px 0;
    box-shadow: var(--shadow);
}

.answers-block {
    display: grid;
    gap: 12px;
}

.answer-option {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-color);
}

.answer-option:hover {
    border-color: var(--primary-color);
    background: #f0f6fc;
}

.answer-option.focused {
    outline: 3px solid rgba(34, 113, 177, 0.3);
    outline-offset: 2px;
}

.answer-option input[type="radio"] {
    margin-right: 15px;
    transform: scale(1.2);
}

.answer-option input[type="radio"]:checked + .answer-text {
    font-weight: 600;
    color: var(--primary-color);
}

.answer-option:has(input:checked) {
    border-color: var(--primary-color);
    background: #f0f6fc;
}

.answer-text {
    flex: 1;
    font-size: 1em;
    line-height: 1.5;
}

/* Progress Indicator */
.progress-indicator {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.progress-bar-container {
    background: #f0f0f1;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: var(--text-color);
    font-size: 0.9em;
}

/* Exam Actions */
.exam-actions {
    text-align: center;
    padding: 30px 0;
}

.btn-submit-exam {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: var(--border-radius);
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.btn-submit-exam:hover {
    background: #017221;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 163, 42, 0.3);
}

.btn-submit-exam:disabled {
    background: #c3c4c7;
    cursor: not-allowed;
    transform: none;
}

/* Save Notification */
.save-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: var(--transition);
}

.save-notification.show {
    opacity: 1;
    transform: translateX(0);
}

/* Exam Result Styles */
.exam-result-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.result-summary {
    background: var(--bg-color);
    border: 3px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.result-summary.passed {
    border-color: var(--success-color);
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
}

.result-summary.failed {
    border-color: var(--danger-color);
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
}

.score-display {
    margin-bottom: 30px;
}

.score-display .score {
    font-size: 4em;
    font-weight: bold;
    color: var(--text-color);
    display: block;
}

.score-display .status {
    font-size: 1.5em;
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 25px;
    display: inline-block;
    margin-top: 15px;
}

.result-summary.passed .status {
    background: var(--success-color);
    color: white;
}

.result-summary.failed .status {
    background: var(--danger-color);
    color: white;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    text-align: left;
}

.stat-item .label {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.stat-item .value {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--text-color);
}

/* Certificate Section */
.certificate-section {
    margin-top: 30px;
}

.btn-certificate {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #8b4513;
    border: 2px solid #daa520;
    padding: 15px 30px;
    border-radius: var(--border-radius);
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.btn-certificate:hover {
    background: linear-gradient(135deg, #ffed4e, #ffd700);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 215, 0, 0.5);
}

/* Answer Review */
.answers-review {
    margin-top: 40px;
}

.answers-review h3 {
    font-size: 1.5em;
    margin-bottom: 25px;
    color: var(--text-color);
}

.answer-review {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.answer-review.correct {
    border-left: 5px solid var(--success-color);
    background: linear-gradient(90deg, #f0fdf4 0%, #ffffff 10%);
}

.answer-review.incorrect {
    border-left: 5px solid var(--danger-color);
    background: linear-gradient(90deg, #fef2f2 0%, #ffffff 10%);
}

.question-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.question-header .question-number {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--text-color);
}

.result-icon {
    font-size: 1.5em;
}

.answers-comparison {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.user-answer, .correct-answer {
    margin-bottom: 10px;
}

.correct-answer {
    color: var(--success-color);
}

.wrong-answer {
    color: var(--danger-color);
}

/* Result Actions */
.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 40px;
    flex-wrap: wrap;
}

.btn-back, .btn-share {
    padding: 12px 25px;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-block;
}

.btn-back {
    background: var(--bg-color);
    color: var(--primary-color);
}

.btn-back:hover {
    background: var(--primary-color);
    color: white;
}

.btn-share {
    background: var(--primary-color);
    color: white;
}

.btn-share:hover {
    background: #135e96;
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .exam-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .exam-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .exam-header h2 {
        font-size: 1.5em;
    }
    
    .exam-timer {
        font-size: 1.2em;
    }
    
    .question-navigation.sticky {
        position: static;
        width: 100%;
        margin-bottom: 20px;
    }
    
    .question-nav-grid {
        grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
        gap: 5px;
    }
    
    .question-nav-item {
        width: 35px;
        height: 35px;
        font-size: 0.9em;
    }
    
    .question-block {
        padding: 20px;
    }
    
    .answer-option {
        padding: 12px;
    }
    
    .result-summary {
        padding: 25px;
    }
    
    .score-display .score {
        font-size: 3em;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .result-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-back, .btn-share {
        width: 100%;
        max-width: 300px;
        text-align: center;
    }
    
    .exam-modal-content {
        margin: 20px;
        width: calc(100% - 40px);
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-cancel, .btn-confirm {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .exam-taking-container {
        padding: 10px;
    }
    
    .exam-header {
        padding: 15px;
    }
    
    .question-block {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .answer-option {
        padding: 10px;
        font-size: 0.95em;
    }
    
    .answer-option input[type="radio"] {
        margin-right: 10px;
    }
    
    .exam-meta {
        gap: 8px;
    }
    
    .exam-meta span {
        font-size: 0.8em;
        padding: 4px 8px;
    }
}

/* Print Styles */
@media print {
    .exam-header,
    .question-navigation,
    .exam-actions,
    .result-actions,
    .save-notification {
        display: none !important;
    }
    
    .exam-taking-container,
    .exam-result-container {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .question-block,
    .result-summary,
    .answer-review {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        margin-bottom: 20px;
    }
    
    .exam-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    body {
        color: #000 !important;
        background: #fff !important;
    }
}

/* High Contrast Mode */
.high-contrast-mode {
    --primary-color: #000080;
    --success-color: #008000;
    --warning-color: #808000;
    --danger-color: #800000;
    --text-color: #000000;
    --bg-color: #ffffff;
    --border-color: #000000;
}

.high-contrast-mode .exam-card,
.high-contrast-mode .question-block,
.high-contrast-mode .answer-option {
    border-width: 3px;
}

.high-contrast-mode .answer-option:hover,
.high-contrast-mode .answer-option:has(input:checked) {
    background: #ffff00;
    color: #000000;
}

/* Focus Styles for Accessibility */
*:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* 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 #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.passed,
.status-badge.active {
    background: var(--success-color);
    color: white;
}

.status-badge.failed,
.status-badge.inactive {
    background: var(--danger-color);
    color: white;
}

.status-badge.in_progress {
    background: var(--warning-color);
    color: white;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.question-block {
    animation: fadeInUp 0.6s ease-out;
}

.answer-option {
    animation: fadeInRight 0.4s ease-out;
    animation-fill-mode: both;
}

.answer-option:nth-child(1) { animation-delay: 0.1s; }
.answer-option:nth-child(2) { animation-delay: 0.2s; }
.answer-option:nth-child(3) { animation-delay: 0.3s; }
.answer-option:nth-child(4) { animation-delay: 0.4s; }

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #ffffff;
        --bg-color: #1a1a1a;
        --border-color: #404040;
    }
    
    .exam-card,
    .question-block,
    .exam-header,
    .result-summary,
    .answer-review {
        background: #2a2a2a;
        color: var(--text-color);
    }
    
    .answer-option {
        background: #2a2a2a;
        color: var(--text-color);
    }
    
    .answer-option:hover {
        background: #3a3a3a;
    }
    
    .exam-meta span {
        background: #3a3a3a;
        color: var(--text-color);
    }
}