@import url('https://fonts.googleapis.com/css2?family=Lobster&display=swap');

/* Minimalist Black & White Test Page Styles */
:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --border-color: #e0e0e0;
    --accent-color: #000000;
    --secondary-bg: transparent;
    --hover-bg: #f8f8f8;
    --disabled-color: #cccccc;
    --border-radius: 6px;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --border-color: #333333;
    --accent-color: #ffffff;
    --secondary-bg: transparent;
    --hover-bg: #111111;
    --disabled-color: #666666;
}

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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Test Page Styles */
.test-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: calc(100vh - 120px);
}

/* Test Start Screen */
.test-start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Центрирование по вертикали */
    text-align: center;
    /* Было 60px сверху — поднимаем блок выше */
    padding: 20px 20px 60px 20px;
    min-height: 70vh; /* Минимальная высота для центрирования */
}

/* Удален .test-title - больше не нужен */

.test-info-form {
    padding: 32px;
    margin-bottom: 16px; /* Уменьшено с 32px до 16px */
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
    border-radius: 32px; /* Увеличено с var(--border-radius) до 32px */
}

.form-group {
    margin-bottom: 24px;
}

/* Тонкая подстройка меток 'Аты-жөні' и 'Пәні' */
.test-info-form .form-label {
    position: relative;
    top: -2px; /* Чуть выше */
    left: 4px; /* Чуть вправо */
}

/* Сокращаем расстояние перед кнопкой старта */
.test-info-form .form-group:last-of-type { /* группа с пәні */
    margin-bottom: 8px; /* Было 24px */
}
.test-info-form .start-test-btn {
    margin-top: 8px; /* Было 16px */
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid var(--border-color); /* Полный бордер */
    font-size: 16px;
    color: var(--text-color);
    background: var(--bg-color);
    transition: border-color 0.2s ease, background-color 0.2s ease;
    font-family: inherit;
    border-radius: 999px; /* Максималды дөңгелектеу */
}
.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: var(--secondary-bg);
}
.form-input::placeholder {
    opacity: 0.5;
}

/* Custom Subject Select */
.custom-subject-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    border-radius: 999px; /* Максималды дөңгелектеу */
    background: var(--bg-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    font-size: 16px;
    color: var(--text-color);
    font-family: inherit;
    min-height: 56px; /* Touch-friendly высота */
}

.custom-select-trigger:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
}

.custom-select-trigger.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.custom-select-text {
    flex: 1;
    text-align: left;
    color: var(--text-color);
}

.custom-select-text.placeholder {
    opacity: 0.6;
    color: #999;
}

.custom-select-arrow {
    transition: transform 0.2s ease;
    color: var(--text-color);
    opacity: 0.6;
    margin-left: 8px;
    flex-shrink: 0;
}

.custom-select-trigger.active .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 24px; /* Было var(--border-radius) */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.3s ease;
    overflow: hidden; /* Чтобы внутренние края тоже были скруглены */
}

.custom-select-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-option {
    padding: 16px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-color);
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
    min-height: 48px; /* Touch-friendly высота */
    display: flex;
    align-items: center;
}

.custom-select-option:last-child {
    border-bottom: none;
}

.custom-select-option:hover {
    background: var(--hover-bg);
}

.custom-select-option.selected {
    background: var(--accent-color);
    color: var(--bg-color);
    font-weight: 500;
}

.start-test-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent-color);
    border: none;
    border-radius: var(--radius-pill); /* Максималды скругление */
    color: var(--bg-color);
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    transition: opacity 0.2s ease;
    margin-top: 16px;
    font-family: inherit;
}

.start-test-btn:hover:not(:disabled) {
    opacity: 0.8;
}

.start-test-btn:disabled {
    background: var(--disabled-color);
    cursor: not-allowed;
}

.test-info {
    padding: 8px 16px 0;
    max-width: 600px;
    width: 100%;
    border: none; /* Убрали линию */
    border-radius: 0;
    text-align: center; /* Центрируем */
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: -20px auto 24px; /* Поднят наверх и увеличен отступ снизу */
    order: -1; /* Помещаем перед формой */
}

.test-info-item {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    transition: opacity 0.35s ease;
}

/* Hover эффектін алып тастадық */
.test-info-item:hover { background: transparent; }

/* Icon removed */

.test-info-item span {
    color: var(--text-color);
    font-size: 24px; /* Увеличено с 15px до 24px */
    line-height: 1.4;
    font-weight: 700; /* Жирный как у search-title */
    font-family: inherit; /* Убрали Lobster, используем системный шрифт */
    letter-spacing: -0.02em; /* Как у search-title */
    transition: opacity .35s ease;
    position: relative;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--text-color) 40%, 
        var(--text-color) 60%, 
        transparent 100%
    );
    -webkit-background-clip: text;
    background-clip: text;
    overflow: hidden;
}

/* Shimmer эффект */
.test-info-item span::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.8) 50%,
        transparent 100%
    );
    z-index: 1;
    opacity: 0;
}

/* Анимация запускается при обновлении текста */
.test-info-item span.shimmer-active::before {
    animation: shimmer 3s ease-in-out; /* Увеличено с 1.8s до 3s для более медленного эффекта */
}

@keyframes shimmer {
    0% {
        left: -100%;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        left: 100%;
        opacity: 0;
    }
}

/* Dark theme shimmer */
[data-theme="dark"] .test-info-item span::before {
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(26, 26, 26, 0.6) 50%, /* Қараңғы режимде 1a1a1a түсі */
        transparent 100%
    );
}

/* Dark mode specific styling for test info icons */
[data-theme="dark"] .test-info-icon {
    color: var(--text-color);
    opacity: 0.7;
}

[data-theme="dark"] .test-info-item:hover .test-info-icon {
    opacity: 1;
    color: #ffffff;
}

/* Smooth icon animations */
@keyframes iconPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.test-info-item:first-child .test-info-icon {
    animation: iconPulse 2s ease-in-out infinite;
    animation-delay: 0s;
}

.test-info-item:nth-child(2) .test-info-icon {
    animation: iconPulse 2s ease-in-out infinite;
    animation-delay: 0.5s;
}

.test-info-item:nth-child(3) .test-info-icon {
    animation: iconPulse 2s ease-in-out infinite;
    animation-delay: 1s;
}

.test-info-item:nth-child(4) .test-info-icon {
    animation: iconPulse 2s ease-in-out infinite;
    animation-delay: 1.5s;
}

/* Test Header Actions */
.test-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px;
    border: none; /* Убрали внешнюю линию */
    border-radius: 0; /* Убрали скругление */
    background: transparent; /* Сделали фон прозрачным */
}

.test-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none; /* Убрали внешнюю линию */
    border-radius: 20px; /* Увеличили border-radius */
    background: transparent;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.test-action-btn:hover {
    background: var(--hover-bg);
}

.test-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.exit-btn {
    background: #f3f4f6; /* Добавили фон для видимости */
    color: #000000 !important; /* Принудительно черный цвет текста */
}

.exit-btn svg {
    color: #000000 !important; /* Принудительно черный цвет иконки */
    stroke: #000000 !important; /* Принудительно черный цвет обводки иконки */
}

.exit-btn:hover {
    background: var(--border-color);
    color: #000000 !important; /* Принудительно черный цвет текста при hover */
}

.exit-btn:hover svg {
    color: #000000 !important; /* Принудительно черный цвет иконки при hover */
    stroke: #000000 !important; /* Принудительно черный цвет обводки иконки при hover */
}

.finish-btn {
    background: #dc2626;
    color: #ffffff;
}

.finish-btn:hover {
    background: #b91c1c;
}

/* Test Question Screen */
.test-question-screen {
    display: none;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.test-question-screen.active {
    display: block;
}

.test-progress-bar {
    display: none; /* Прогресс барды толығымен жасырамыз */
}

.question-card {
    border: 1px solid var(--border-color);
    border-radius: 24px; /* Увеличили с var(--border-radius) до 24px */
    padding: 32px;
    margin-bottom: 32px;
}

.question-number {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-color);
    margin-bottom: 16px;
    opacity: 0.6;
    text-align: center; /* Центрируем номер вопроса */
}

.question-text {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 32px;
    font-weight: 400;
}

.options-list {
    list-style: none;
}

.option-item {
    margin-bottom: 12px;
}

.option-button {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px; /* Увеличили с var(--border-radius) до 20px */
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
    color: var(--text-color);
    text-align: left;
    font-family: inherit;
}

.option-button:hover {
    background: var(--hover-bg);
}

.option-button.selected {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    font-weight: 400;
    font-size: 12px;
    color: var(--text-color);
    margin-right: 16px;
    flex-shrink: 0;
}

.option-button.selected .option-letter {
    background: var(--bg-color);
    color: var(--accent-color);
    border-color: var(--bg-color);
}

.question-navigation {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.nav-btn {
    padding: 12px 24px;
    border: 1px solid var(--border-color);
    border-radius: 20px; /* Увеличили с var(--border-radius) до 20px */
    background: transparent;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.nav-btn:hover:not(:disabled) {
    background: var(--hover-bg);
}

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

.nav-btn.next-btn {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
}

.nav-btn.next-btn:hover:not(:disabled) {
    background: var(--bg-color);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Test Results Screen */
.test-results-screen {
    display: none;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.test-results-screen.active {
    display: block;
}

/* Results actions - жоғарғы бөлікке орналастырылған */
.results-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.results-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.results-title {
    font-size: 2rem;
    font-weight: 200;
    color: var(--text-color);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.results-subtitle {
    font-size: 16px;
    color: var(--text-color);
    opacity: 0.6;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px;
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.summary-card {
    padding: 24px;
    text-align: center;
    border-right: 1px solid var(--border-color);
}

.summary-card:last-child {
    border-right: none;
}

.summary-value {
    font-size: 1.8rem;
    font-weight: 200;
    color: var(--text-color);
    margin-bottom: 8px;
}

.summary-label {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.6;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px auto;
    position: relative;
}

.score-text {
    font-size: 1.5rem;
    font-weight: 200;
    color: var(--text-color);
}

.detailed-results {
    margin-top: 40px;
}

.detailed-title {
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-color);
    margin-bottom: 24px;
    text-align: center;
}

.question-result {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 8px;
}

.question-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.question-result-number {
    font-weight: 400;
    color: var(--text-color);
    font-size: 14px;
}

.question-result-status {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 400;
    border: 1px solid;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-result-status.correct {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
}

.question-result-status.incorrect {
    background: transparent;
    color: var(--text-color);
    border-color: var(--border-color);
}

.question-result-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.results-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1px;
    margin-top: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-decoration: none;
}

.action-btn:last-child {
    border-right: none;
}

.action-btn:hover {
    background: var(--hover-bg);
}

.action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Dark mode option color fixes */
[data-theme="dark"] .option-button {
    background: #2d3748;
    border: 1px solid #4a5568;
    color: #e2e8f0;
}

[data-theme="dark"] .option-button:hover {
    background: #374151;
    border-color: #6b7280;
}

[data-theme="dark"] .option-button.selected {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

[data-theme="dark"] .option-button.selected .option-letter {
    background: #000000;
    color: #ffffff;
    border-color: #000000;
}

[data-theme="dark"] .option-letter {
    border-color: #4a5568;
    color: #e2e8f0;
}

/* Answer option styles for detailed results in dark mode */
[data-theme="dark"] .answer-option.option-correct {
    background-color: #1e4620 !important;
    border: 1px solid #28a745 !important;
    color: #4ade80 !important;
}

[data-theme="dark"] .answer-option.option-correct-selected {
    background-color: #1e4620 !important;
    border: 2px solid #28a745 !important;
    color: #4ade80 !important;
    font-weight: 600 !important;
}

[data-theme="dark"] .answer-option.option-incorrect-selected {
    background-color: #4a1e1e !important;
    border: 2px solid #dc3545 !important;
    color: #f87171 !important;
    font-weight: 600 !important;
}

[data-theme="dark"] .answer-option.option-neutral {
    background-color: #2d3748 !important;
    border: 1px solid #4a5568 !important;
    color: #e2e8f0 !important;
}

/* Question result text styling for dark mode */
[data-theme="dark"] .question-result-text {
    background-color: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

/* Explanation styling for dark mode */
[data-theme="dark"] .explanation {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
}

[data-theme="dark"] .explanation-title {
    color: #fbbf24 !important;
}

[data-theme="dark"] .explanation-text {
    color: #d1d5db !important;
}

/* Exit button - всегда черный цвет в любом режиме */
[data-theme="dark"] .exit-btn {
    color: #000000 !important; /* Черный цвет текста в темном режиме */
}

[data-theme="dark"] .exit-btn svg {
    color: #000000 !important; /* Черный цвет иконки в темном режиме */
    stroke: #000000 !important; /* Черный цвет обводки иконки в темном режиме */
}

[data-theme="dark"] .exit-btn:hover {
    color: #000000 !important; /* Черный цвет текста при hover в темном режиме */
}

[data-theme="dark"] .exit-btn:hover svg {
    color: #000000 !important; /* Черный цвет иконки при hover в темном режиме */
    stroke: #000000 !important; /* Черный цвет обводки иконки при hover в темном режиме */
}

/* Responsive design */
@media (max-width: 768px) {
    .test-container {
        padding: 24px 16px;
    }
    
    .test-title {
        font-size: 2rem;
    }
    
    .test-info-form {
        padding: 24px;
    }
    
    .question-card {
        padding: 24px;
    }
    
    .question-text {
        font-size: 16px;
    }
    
    /* Мобильді құрылғыларда жоғарғы батырмалар */
    .test-header-actions {
        flex-direction: column;
        gap: 12px;
        padding: 20px 16px;
        margin-bottom: 20px;
    }
    
    .test-action-btn {
        width: 100%;
        padding: 16px 20px;
        font-size: 16px;
        gap: 12px;
        min-height: 48px; /* Touch target size */
        justify-content: center;
    }
    
    .test-action-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .results-summary {
        grid-template-columns: 1fr;
    }
    
    .summary-card {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .summary-card:last-child {
        border-bottom: none;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .action-btn {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .action-btn:last-child {
        border-bottom: none;
    }
    
    .answer-row {
        flex-direction: column;
        gap: 4px;
    }
    
    .answer-label {
        min-width: auto;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
}

/* Кіші экрандар үшін қосымша стиль */
@media (max-width: 480px) {
    .test-header-actions {
        padding: 16px 12px;
        margin-bottom: 16px;
    }
    
    .test-action-btn {
        padding: 18px 16px;
        font-size: 15px;
        border-radius: 20px; /* Увеличили с 8px до 20px для соответствия общему стилю */
        font-weight: 500;
    }
    
    .question-card {
        padding: 20px 16px;
        margin-bottom: 20px;
    }
}

/* Touch оптимизациясы */
@media (hover: none) and (pointer: coarse) {
    .test-action-btn {
        min-height: 48px;
        padding: 16px 20px;
        font-size: 16px;
    }
    
    .test-action-btn:hover {
        background: transparent;
    }
    
    .test-action-btn:active {
        background: var(--hover-bg);
        transform: scale(0.98);
    }
    
    .finish-btn:active {
        background: #b91c1c;
        transform: scale(0.98);
    }
}

/* Extra override: максималды скругление старт батырмасы */
.start-test-btn {
    border-radius: 9999px !important; /* Ең жоғарғы pill эффект */
}
