/* ==================== AI TEST GENERATOR STYLES ==================== */

/* Модальне вікно */
.ai-test-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.ai-test-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-test-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.ai-test-content {
    position: relative;
    background: var(--white, #fff);
    border-radius: 25px;
    padding: 40px;
    max-width: 900px;
    width: 95%;
    max-height: 92vh;
    overflow-y: auto;
    border: 3px solid var(--black, #1a1a2e);
    box-shadow: 10px 10px 0px var(--black, #1a1a2e);
    animation: modalSlideIn 0.3s ease;
}

/* Хедер */
.ai-test-header {
    text-align: center;
    margin-bottom: 30px;
}

.ai-test-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    background: var(--lime, #c8f547);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    color: var(--black, #1a1a2e);
    border: 3px solid var(--black, #1a1a2e);
    box-shadow: 5px 5px 0px var(--black, #1a1a2e);
}

.ai-test-icon.spinning {
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ai-test-header h2 {
    font-size: 1.8em;
    font-weight: 900;
    color: var(--black, #1a1a2e);
    margin: 0 0 8px;
}

.ai-test-header p {
    color: var(--darkgray, #666);
    font-size: 1em;
    margin: 0;
}

/* Кроки */
.ai-step h3 {
    font-size: 1.2em;
    font-weight: 700;
    margin: 0 0 20px;
    color: var(--black, #1a1a2e);
}

/* Сітка тем */
.ai-topics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.ai-topic-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 10px;
    border-radius: 16px;
    border: 3px solid var(--black, #1a1a2e);
    background: var(--white, #fff);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 4px 4px 0px var(--black, #1a1a2e);
    font-family: inherit;
}

.ai-topic-btn:hover {
    box-shadow: 6px 6px 0px var(--black, #1a1a2e);
    transform: translate(-2px, -2px);
    background: var(--lime, #c8f547);
}

.ai-topic-btn:active {
    box-shadow: 2px 2px 0px var(--black, #1a1a2e);
    transform: translate(2px, 2px);
}

.topic-icon {
    font-size: 2em;
}

.topic-name {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--black, #1a1a2e);
}

/* Сітка рівнів */
.ai-levels-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-level-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 25px;
    border-radius: 16px;
    border: 3px solid var(--black, #1a1a2e);
    background: var(--white, #fff);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 4px 4px 0px var(--black, #1a1a2e);
    font-family: inherit;
    text-align: left;
}

.ai-level-btn:hover {
    box-shadow: 6px 6px 0px var(--black, #1a1a2e);
    transform: translate(-2px, -2px);
    background: var(--lime, #c8f547);
}

.level-icon {
    font-size: 1.8em;
}

.level-name {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--black, #1a1a2e);
    display: block;
}

.level-desc {
    font-size: 0.85em;
    color: var(--darkgray, #666);
    font-weight: 500;
}

/* Кнопка назад */
.ai-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    border: 2px solid var(--black, #1a1a2e);
    background: var(--white, #fff);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    font-family: inherit;
    margin-bottom: 20px;
    transition: all 0.2s;
    box-shadow: 3px 3px 0px var(--black, #1a1a2e);
}

.ai-back-btn:hover {
    background: #f0f0f0;
}

/* Лоадер */
.ai-loading-animation {
    text-align: center;
    padding: 40px 0;
}

.ai-loading-text {
    color: var(--darkgray, #666);
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Помилка */
.ai-error {
    text-align: center;
    padding: 30px 0;
}

.ai-error i {
    font-size: 3em;
    color: var(--pink, #ff6b9d);
    margin-bottom: 15px;
}

.ai-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 14px;
    border: 3px solid var(--black, #1a1a2e);
    background: var(--lime, #c8f547);
    cursor: pointer;
    font-size: 1em;
    font-weight: 700;
    font-family: inherit;
    margin-top: 20px;
    transition: all 0.2s;
    box-shadow: 4px 4px 0px var(--black, #1a1a2e);
}

.ai-retry-btn:hover {
    box-shadow: 6px 6px 0px var(--black, #1a1a2e);
    transform: translate(-2px, -2px);
}

/* Результат тесту */
.ai-test-result {
    text-align: center;
    padding: 20px 0;
}

.result-emoji {
    font-size: 4em;
    margin-bottom: 10px;
}

.ai-test-result h2 {
    font-size: 1.8em;
    font-weight: 900;
    color: var(--black, #1a1a2e);
    margin: 0 0 20px;
}

.result-score {
    font-size: 3em;
    font-weight: 900;
    color: var(--black, #1a1a2e);
}

.result-percentage {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--lime, #c8f547);
    background: var(--black, #1a1a2e);
    display: inline-block;
    padding: 5px 20px;
    border-radius: 10px;
    margin: 10px 0;
}

.result-message {
    font-size: 1.1em;
    color: var(--darkgray, #666);
    margin: 15px 0 25px;
}

.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 14px;
    border: 3px solid var(--black, #1a1a2e);
    background: var(--lime, #c8f547);
    cursor: pointer;
    font-size: 1em;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 4px 4px 0px var(--black, #1a1a2e);
}

.btn-retry:hover {
    box-shadow: 6px 6px 0px var(--black, #1a1a2e);
    transform: translate(-2px, -2px);
}

/* Пояснення AI */
.ai-explanation-popup {
    margin-top: 15px;
    padding: 15px 20px;
    background: var(--lime, #c8f547);
    border: 3px solid var(--black, #1a1a2e);
    border-radius: 14px;
    font-size: 0.95em;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    box-shadow: 4px 4px 0px var(--black, #1a1a2e);
}

.ai-explanation-popup.show {
    opacity: 1;
    transform: translateY(0);
}

.ai-explanation-popup i {
    color: var(--orange, #ffa726);
    margin-right: 8px;
}

/* Стилі відповідей для AI-тесту */
.ai-test-content .correct-answer {
    background: var(--lime, #c8f547) !important;
    border-color: var(--black, #1a1a2e) !important;
    box-shadow: 5px 5px 0px var(--black, #1a1a2e);
}

.ai-test-content .wrong-answer {
    background: var(--pink, #ff6b9d) !important;
    color: var(--white, #fff) !important;
    border-color: var(--black, #1a1a2e) !important;
}

/* Кнопка "Згенерувати тест" на сторінці testbykoodi */
.ai-generate-section {
    text-align: center;
    padding: 40px 0;
}

.btn-ai-generate {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 20px 40px;
    border-radius: 20px;
    border: 3px solid var(--black, #1a1a2e);
    background: linear-gradient(135deg, var(--lime, #c8f547) 0%, var(--orange, #ffa726) 100%);
    color: var(--black, #1a1a2e);
    font-size: 1.2em;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 6px 6px 0px var(--black, #1a1a2e);
}

.btn-ai-generate:hover {
    box-shadow: 8px 8px 0px var(--black, #1a1a2e);
    transform: translate(-2px, -2px);
}

.btn-ai-generate:active {
    box-shadow: 3px 3px 0px var(--black, #1a1a2e);
    transform: translate(3px, 3px);
}

.btn-ai-generate i {
    font-size: 1.3em;
}

/* ==================== ОВЕРРАЙДИ для тесту всередині модалки ==================== */
/* Існуючі стилі .test-section-exact розраховані на повноекранний режим
   (padding: 80px 50px, max-width: 1300px). В модалці 700px це ламає лейаут. */

.ai-test-content .test-section-exact {
    padding: 20px 15px;
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    margin: 0;
}

.ai-test-content .answers-grid-exact {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.ai-test-content .answer-option-exact .answer-content {
    padding: 12px 15px;
}

.ai-test-content .question-title-exact {
    font-size: 1.1em;
    line-height: 1.4;
}

.ai-test-content .code-example-block-exact {
    margin: 15px 0;
    font-size: 0.85em;
}

.ai-test-content .header-content {
    margin-bottom: 10px;
}

.ai-test-content .icon-image-for-test {
    width: 30px;
    height: 30px;
}

/* Кнопка "Далі" */
.ai-next-btn {
    display: none;
    margin: 20px auto 0;
    padding: 14px 40px;
    border-radius: 14px;
    border: 3px solid var(--black, #1a1a2e);
    background: var(--lime, #c8f547);
    color: var(--black, #1a1a2e);
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 4px 4px 0px var(--black, #1a1a2e);
}

.ai-next-btn.visible {
    display: block;
}

.ai-next-btn:hover {
    box-shadow: 6px 6px 0px var(--black, #1a1a2e);
    transform: translate(-2px, -2px);
}

/* Чекбокс авто-перехід */
.ai-auto-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 0.85em;
    color: var(--darkgray, #666);
    font-weight: 600;
}

.ai-auto-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--lime, #c8f547);
    cursor: pointer;
}

.ai-auto-toggle label {
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-test-content {
        padding: 25px;
        margin: 15px;
    }

    .ai-topics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ai-test-header h2 {
        font-size: 1.4em;
    }

    .btn-ai-generate {
        padding: 16px 30px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    .ai-test-content {
        padding: 20px;
        margin: 10px;
        border-radius: 20px;
    }

    .ai-topics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ai-topic-btn {
        padding: 15px 8px;
    }

    .ai-test-content .answers-grid-exact {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ai-test-content .test-section-exact {
        padding: 15px 10px;
    }
}
