/* =================== */
/*  РЕЖИМ ЭКЗАМЕНА     */
/* =================== */

/* Таймер */
.exam-timer {
  position: sticky;
  top: 158px;
  z-index: 99;
  background: var(--burgundy);
  color: #fff;
  text-align: center;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 25px;
  box-shadow: 0 4px 12px rgba(128, 0, 32, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.timer-icon {
  font-size: 20px;
}

.exam-timer.warning {
  background: #e67e22;
  animation: pulse 1s infinite;
}

.exam-timer.danger {
  background: #e74c3c;
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Карточки в режиме экзамена — не сворачиваются */
.exam-mode .question-card {
  transition: none;
}

.exam-mode .question-card.answered {
  opacity: 0.85;
  border-left: 4px solid var(--burgundy);
}

.exam-mode .question-card.answered .option-item,
.exam-mode .question-card.answered .flag-option {
  pointer-events: none;
}

.exam-mode .question-card.answered .option-item.correct {
  background: rgba(34, 197, 94, 0.08);
  border-color: var(--green-success);
}

.exam-mode .question-card.answered .option-item.wrong {
  background: rgba(239, 68, 68, 0.05);
  border-color: #ef4444;
}

/* Адаптив */
@media (max-width: 700px) {
  .exam-timer {
    top: 145px;
    font-size: 16px;
    padding: 8px 12px;
  }
}

/* =================== */
/*  ЭКЗАМЕН: ПОДСВЕТКА  */
/* =================== */

/* Карточка, в которой все ответы даны — нейтральная */
.question-card.answered {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Невыбранные опции — скрываем */
.question-card.answered .option-item:not(.selected) {
  opacity: 0.3;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.question-card.answered .flag-option:not(.selected) {
  opacity: 0.3;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Выбранный ответ — выделяем нейтрально */
.question-card.answered .option-item.selected {
  background: #e2e8f0;
  border-color: #94a3b8;
  font-weight: 600;
}

.question-card.answered .flag-option.selected {
  border-color: #64748b;
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.3);
}

/* Анимация */
.question-card {
  transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* ========================================
   КОМПАКТНАЯ ПЛАШКА ПРОГРЕССА
   ======================================== */
.exam-progress-compact {
    position: fixed;
    right: 0;
    top: 58%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 6px;
    border-radius: 14px 0 0 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(128, 0, 32, 0.15);
    border-right: none;
    transition: all 0.3s ease;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .exam-progress-compact {
        padding: 6px 4px;
        gap: 4px;
        border-radius: 12px 0 0 12px;
        top: 56%;
    }
    .exam-progress-compact .progress-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .exam-progress-compact {
        padding: 5px 3px;
        gap: 3px;
        border-radius: 10px 0 0 10px;
        top: 54%;
    }
    .exam-progress-compact .progress-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

.exam-progress-compact .progress-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
}

.exam-progress-compact .progress-btn:hover {
    background: rgba(128, 0, 32, 0.08);
    color: #800020;
    transform: scale(1.05);
}

.exam-progress-compact .progress-btn:active {
    transform: scale(0.95);
}

.exam-progress-compact .progress-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.exam-progress-compact .progress-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: #800020;
    border: 2px solid white;
    padding: 0 3px;
}

.exam-progress-compact .progress-btn.has-stats {
    color: #800020;
}

/* ========================================
   МОДАЛЬНОЕ ОКНО СТАТИСТИКИ
   ======================================== */
.stats-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.stats-modal {
    background: white;
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.stats-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stats-modal-header h2 {
    font-size: 22px;
    font-weight: 900;
    color: #1a1a2e;
    margin: 0;
}

.stats-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f1f5f9;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.stats-modal-close:hover {
    background: #fee2e2;
    color: #991b1b;
}

.stats-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stats-item {
    text-align: center;
    padding: 14px 10px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.stats-item .number {
    font-size: 28px;
    font-weight: 900;
    display: block;
}

.stats-item .label {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    display: block;
}

.stats-item .number.gold { color: #B45309; }
.stats-item .number.green { color: #22c55e; }
.stats-item .number.yellow { color: #eab308; }
.stats-item .number.red { color: #ef4444; }

.stats-history {
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
    margin-top: 4px;
}

.stats-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.stats-history-item .date {
    color: #6b7280;
    font-size: 12px;
}

.stats-history-item .dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
}

.stats-empty {
    text-align: center;
    padding: 30px 20px;
    color: #6b7280;
}

.stats-empty .emoji {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========================================
   УВЕДОМЛЕНИЯ
   ======================================== */
.exam-notification {
    position: fixed;
    bottom: 20px;
    right: 70px;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    z-index: 10001;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
}

@media (max-width: 768px) {
    .exam-notification {
        right: 55px;
        font-size: 13px;
        padding: 10px 16px;
        max-width: calc(100% - 70px);
    }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========================================
   СТИЛИ ДЛЯ КАРТОЧЕК ВОПРОСОВ (СТАРАЯ ВЕРСИЯ)
   ======================================== */
.question-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.question-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.question-card .q-tag {
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    background: #800020;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-bottom: 18px;
}

.question-card .question-hint-area {
    margin-bottom: 14px;
}

.question-card .audio-instruction {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7fafc;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
    color: #1a202c;
}

.question-card .instruction-icon {
    font-size: 20px;
}

.question-card .audio-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #edf2f7;
    padding: 10px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.question-card .audio-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #800020;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.question-card .audio-icon:hover {
    background: #9a0028;
}

.question-card .audio-icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.question-card .audio-icon .hidden {
    display: none;
}

.question-card .audio-progress {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #cbd5e0;
    border-radius: 4px;
    outline: none;
}

.question-card .audio-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #800020;
    cursor: pointer;
}

.question-card .audio-progress::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #800020;
    cursor: pointer;
    border: none;
}

.question-card .time-display {
    color: #4a5568;
    font-size: 14px;
    min-width: 44px;
    font-variant-numeric: tabular-nums;
}

.question-card .reading-box {
    background: #f7fafc;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 18px;
    border-left: 4px solid #800020;
    font-size: 15px;
    line-height: 1.7;
    color: #2d3748;
}

.question-card .option-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    background: #f7fafc;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.5;
    color: #2d3748;
}

.question-card .option-item:hover {
    background: #edf2f7;
    border-color: #e2e8f0;
}

.question-card .option-item.selected {
    background: #ebf4ff;
    border-color: #800020;
}

.question-card .option-item input[type="radio"] {
    display: none;
}

.question-card .option-item.text-sm {
    font-size: 14px;
    padding: 8px 14px;
}

/* ========================================
   ФЛАГИ (16 задание) - КАК В РЕЖИМЕ ОБУЧЕНИЯ
   ======================================== */
.question-card .flag-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.question-card .flag-option {
    border: 3px solid var(--border-color, #e5e7eb);
    border-radius: 14px;
    padding: 8px;
    cursor: pointer;
    transition: 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.question-card .flag-option:hover {
    border-color: var(--burgundy, #800020);
}

.question-card .flag-option.selected {
    border-color: var(--burgundy, #800020);
    background: var(--burgundy-soft, rgba(128, 0, 32, 0.04));
}

.question-card .flag-option img {
    width: 100px;
    height: auto;
    display: block;
    border-radius: 4px;
}

.question-card .flag-option input[type="radio"] {
    display: none;
}

/* Адаптация для мобильных */
@media (max-width: 700px) {
    .question-card .flag-grid {
        gap: 12px;
    }
    .question-card .flag-option img {
        width: 70px;
    }
}

@media (max-width: 480px) {
    .question-card .flag-grid {
        gap: 8px;
    }
    .question-card .flag-option {
        padding: 5px;
        border-radius: 10px;
        border-width: 2px;
    }
    .question-card .flag-option img {
        width: 55px;
    }
}

/* Состояние для отвеченных карточек */
.question-card.answered .flag-option:not(.selected) {
    opacity: 0.4;
}

.question-card.answered .flag-option.selected {
    opacity: 1;
    border-color: #64748b;
}

.question-card .text-answer-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.question-card .input-text {
    flex: 1;
    min-width: 180px;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    transition: border 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
    color: #2d3748;
}

.question-card .input-text:focus {
    outline: none;
    border-color: #800020;
    box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.08);
}

.question-card .input-text.answered-input {
    background: #f7fafc;
    border-color: #cbd5e0;
    color: #4a5568;
    cursor: not-allowed;
}

.question-card .submit-text-btn {
    padding: 10px 24px;
    background: #800020;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.question-card .submit-text-btn:hover {
    background: #9a0028;
}

.question-card.answered {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.question-card.answered .option-item,
.question-card.answered .flag-option {
    pointer-events: none;
}

.question-card.answered .option-item:not(.selected) {
    opacity: 0.35;
}

.question-card.answered .flag-option:not(.selected) {
    opacity: 0.35;
}

.question-card.answered .option-item.selected {
    background: #edf2f7;
    border-color: #a0aec0;
}

.question-card.answered .flag-option.selected {
    border-color: #a0aec0;
}

.question-card.unanswered-warning {
    border: 2px solid #800020 !important;
    box-shadow: 0 0 0 4px rgba(128, 0, 32, 0.12) !important;
}

.question-card .unanswered-alert {
    background: #fff5f5;
    border: 1px solid #fc8181;
    color: #c53030;
    padding: 12px 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 16px;
    text-align: center;
}

/* ========================================
   КНОПКА РЕЗУЛЬТАТА
   ======================================== */
.exam-submit-wrapper {
    text-align: center;
    margin: 32px 0 20px;
    display: block;
}

.btn-result {
    padding: 16px 48px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.5px;
}

.btn-result-primary {
    background: #800020;
    color: #fff;
    box-shadow: 0 4px 16px rgba(128, 0, 32, 0.3);
}

.btn-result-primary:hover {
    background: #9a0028;
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(128, 0, 32, 0.35);
}

.btn-result-primary:active {
    transform: translateY(0);
}

/* ========================================
   РЕЗУЛЬТАТЫ
   ======================================== */
.result-container {
    padding: 20px 0;
}

/* ========================================
   РЕКЛАМНЫЕ КОНТЕЙНЕРЫ
   ======================================== */
.ad-container {
    min-height: 250px;
    margin: 20px 0;
}

/* ========================================
   ИСПРАВЛЕНИЕ СКРОЛЛА
   ======================================== */
.question-card,
.result-container {
    scroll-margin-top: 140px;
}

@media (max-width: 700px) {
    .question-card,
    .result-container {
        scroll-margin-top: 120px;
    }
}

/* ========================================
   АДАПТАЦИЯ
   ======================================== */
@media (max-width: 640px) {
    .question-card {
        padding: 16px 18px;
    }
    
    .question-card .text-answer-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .question-card .input-text {
        min-width: 100%;
    }
    
    .btn-result {
        padding: 14px 28px;
        font-size: 16px;
        width: 100%;
    }
    
    .stats-summary {
        grid-template-columns: 1fr 1fr;
    }
    
    .stats-item:last-child {
        grid-column: span 2;
    }
}