/* Step Indicator - выровнен по центру */
.step-indicator {
    display: flex;
    justify-content: center; /* Центрируем нумерацию */
    gap: 1rem;
    margin-bottom: 1rem;
}

.step-indicator-item {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #e9ecef;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: all 0.25s ease;
}

.step-indicator-item.active {
    background-color: #0d6efd;
    color: #fff;
    transform: scale(1.1);
}

.step-indicator-item.has-error {
    background-color: #e74c3c;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.12);
    transform: scale(1.05);
}

body.survey-page {
    background-color: #f4f7f6;
}

/* Для body теперь тоже зададим flex, чтобы main-content мог расти */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Новый контейнер для основного контента */
.main-content {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 0 1rem 0; /* Уменьшили нижний padding */
}

/* Контейнер опросника с гуттерами */
.survey-container {
    width: 100%; 
    max-width: 700px; /* Нормальная ширина для desktop */
    margin: 1.5rem auto;
    padding: 2rem;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    border-top: 4px solid #0d6efd;
}


/* Fix subtitle background covering lines */
.section-title {
    background: transparent !important;
    overflow: hidden;
    padding: 0 1rem;
    margin-bottom: 1rem !important;
}

.section-title h1 {
    margin-bottom: 0 !important; /* Убираем отступ у h1 (перекрываем mb-4 из Bootstrap) */
}

.sub-style {
    background: transparent !important;
}

.sub-style h5 {
    background: transparent !important;
}

.sub-title {
    background: transparent !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
}

/* Планшеты и средние экраны */
@media (max-width: 991px) {
    .survey-container {
        max-width: 600px;
        padding: 1.75rem;
    }
}

/* Мобильные устройства */
@media (max-width: 767px) {
    body {
        min-height: auto !important; /* Убираем фиксированную высоту */
        max-height: 100vh; /* Ограничиваем высоту экраном */
        overflow-y: auto; /* Прокрутка только внутри body */
    }
    
    .main-content {
        padding: 0.5rem 0 0.5rem 0;
        align-items: flex-start;
        flex-shrink: 0; /* Не сжимаем контент */
    }

    .survey-container {
        max-width: 420px;
        margin: 0.5rem auto 0.5rem auto; /* Уменьшили все margins */
        padding: 1.5rem;
        border-radius: 10px;
        box-shadow: none;
    }
    
    .step-indicator {
        gap: 0.5rem;
    }
    
    .container.py-5 {
        padding-top: 1rem !important; /* Уменьшили верхний отступ */
        padding-bottom: 0.5rem !important;
    }
    
    /* Убираем лишний нижний отступ у кнопок навигации */
    .d-flex.justify-content-between {
        margin-bottom: 0.5rem !important;
    }
    
    .section-title {
        margin-bottom: 1rem !important; /* Меньше отступ на мобильных */
    }
    
    .step-indicator-item {
        width: 26px;
        height: 26px;
        font-size: 0.9rem;
    }
    
    #prev-btn, #next-btn, #submit-btn {
        padding: 0.75rem 2rem !important;
        font-size: 0.95rem;
    }
}

/* Очень маленькие экраны */
@media (max-width: 400px) {
    .survey-container {
        max-width: 380px;
        padding: 1.25rem;
        margin: 0.75rem auto;
    }
    
    .step-indicator {
        gap: 0.4rem;
    }
    
    .section-title h1 {
        font-size: 1.5rem !important;
    }
}

/* --- Step Animation Styling --- */
.survey-steps-container {
    position: relative;
    overflow: visible; /* Не обрезаем контент, когда много вариантов */
    transition: height 0.4s ease-in-out;
}

.survey-step {
    transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transform: translateX(50px);
    pointer-events: none;
}

.survey-step.active {
    opacity: 1;
    transform: translateX(0);
    position: relative;
    pointer-events: auto;
    overflow: visible; /* Не обрезаем кастомные поля */
    z-index: 1; /* Поднимаем над другими элементами */
}

.survey-step.was-active {
    position: absolute;
}

/* --- Success Modal Styling --- */
.success-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin: 0;
    padding: 0;
}

.success-modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    position: relative;
    margin: auto;
}

.success-modal-overlay.visible {
    opacity: 1;
}

.success-modal-overlay.visible .success-modal-content {
    transform: scale(1);
}

.success-modal-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    background-color: #28a745;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2rem;
}

.success-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.success-modal-text {
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.success-modal-actions a {
    display: block;
    background-color: #e21e3c;
    color: #fff;
    padding: 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 0.75rem;
    transition: background-color 0.2s ease;
}

.success-modal-actions a:hover {
    background-color: #c41a33;
}

.success-modal-close {
    background: none;
    border: none;
    color: #6c757d;
    padding: 0.5rem 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
    font-weight: 500;
    text-decoration: underline;
}

.success-modal-close:hover {
    color: #212529;
}

/* Error Modal Styling */
.error-modal .success-modal-icon.error-icon {
    background-color: #dc3545; /* Красный цвет для ошибки */
    color: #fff;
}

.error-modal .success-modal-title {
    color: #dc3545; /* Красный заголовок */
}

.error-modal .success-modal-text {
    white-space: pre-line; /* Поддержка переносов строк */
}

.error-modal .error-close {
    background-color: #dc3545;
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease;
}

.error-modal .error-close:hover {
    background-color: #bb2d3b;
    text-decoration: none;
}


/* --- Custom Choice Styling (Polished) --- */
.survey-choices {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    grid-auto-rows: 1fr;
}

.children-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .survey-choices {
        grid-template-columns: repeat(2, 1fr);
    }
}

.option-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.survey-choice-item {
    position: relative;
    flex: 1;
    display: flex;
}

.survey-choice-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.survey-choice-label {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    height: 100%;
    font-size: 1rem;
}

.survey-choice-label:hover {
    border-color: #adb5bd;
}

.survey-choice-input:checked + .survey-choice-label {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

.survey-choice-label::before {
    content: '';
    flex-shrink: 0;
    display: inline-block;
    width: 22px;
    height: 22px;
    margin-right: 12px;
    border: 2px solid #adb5bd;
    background-color: #fff;
    transition: all 0.2s ease;
}

.survey-choice-input[type="radio"] + .survey-choice-label::before {
    border-radius: 50%;
}

.survey-choice-input[type="checkbox"] + .survey-choice-label::before {
    border-radius: 4px;
}

.survey-choice-input:checked + .survey-choice-label::before {
    border-color: #0d6efd;
    background-color: #0d6efd;
    box-shadow: inset 0 0 0 4px #fff;
}

.survey-choice-input[type="checkbox"]:checked + .survey-choice-label::before {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='white' d='M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z'/%3e%3c/svg%3e");
    box-shadow: none;
}

.is-group-header .survey-choice-label {
    font-weight: bold;
    background-color: #e9ecef;
}

.is-group-header .survey-choice-label::before {
    display: none;
}

.toggle-icon {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.is-open .toggle-icon {
    transform: rotate(180deg);
}

.children-container {
    padding-left: 2.5rem;
    margin-top: 0.75rem;
}

.option-wrapper.level-1 {
    margin-left: 1.5rem;
}

.option-wrapper.level-2 {
    margin-left: 3rem;
}

/* Кастомное поле ввода для комментариев */
.custom-input-wrapper {
    grid-column: 1 / -1; /* Занимает всю ширину grid */
    margin-top: 0.75rem;
    position: relative;
    z-index: 2;
}

.custom-input-field {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.custom-input-field:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

