/* ========== MODAL STYLES ========== */

.cta-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cta-modal.active {
    display: flex;
    opacity: 1;
}

.cta-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1;
}

.cta-modal-container {
    position: relative;
    background: white;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 2;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 10px 30px rgba(0, 183, 7, 0.15);
    border: 1px solid rgba(0, 183, 7, 0.2);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Стилизация скроллбара */
.cta-modal-container::-webkit-scrollbar {
    width: 6px;
}

.cta-modal-container::-webkit-scrollbar-track {
    background: rgba(0, 183, 7, 0.05);
    border-radius: 3px;
}

.cta-modal-container::-webkit-scrollbar-thumb {
    background: rgba(0, 183, 7, 0.3);
    border-radius: 3px;
}

.cta-modal-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 183, 7, 0.5);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cta-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid rgba(0, 183, 7, 0.2);
    border-radius: 50%;
    color: #1a2e35;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 3;
    box-shadow: 0 4px 12px rgba(0, 183, 7, 0.1);
}

.cta-modal-close:hover {
    background: linear-gradient(135deg, #00B707, #00B707);
    color: white;
    transform: rotate(90deg);
    border-color: transparent;
}

.cta-modal-content {
    padding: 0;
}

/* Компактная форма */
.compact-form {
    padding: 25px 25px 20px; /* немного уменьшили отступы */
}

.form-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 183, 7, 0.1);
}

.form-title {
    font-size: 22px;
    color: #1a2e35;
    margin-bottom: 6px;
    font-weight: 700;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.form-title i {
    color: #00B707;
    font-size: 20px;
}

.form-subtitle {
    font-size: 13px;
    color: #5a6b6f;
    line-height: 1.4;
    opacity: 0.9;
}

/* Поля формы */
.form-fields {
    display: grid;
    gap: 12px;
    margin-bottom: 15px;
}

/* Единый стиль для всех полей ввода и кастомного селекта */
.popup-field,
.select-selected {
    width: 100%;
    padding: 12px 14px; /* единая высота */
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid rgba(0, 183, 7, 0.15);
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    color: #1a2e35;
    transition: all 0.2s ease;
    box-sizing: border-box;
    line-height: normal;
}

.popup-field:focus,
.select-selected:focus-within {
    outline: none;
    border-color: #00B707;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 183, 7, 0.1);
}

.popup-field::placeholder {
    color: #5a6b6f;
    opacity: 0.6;
    font-size: 14px;
}

textarea.popup-field {
    min-height: 80px;
    resize: vertical;
}

/* Группа телефона с кастомным селектом */
.phone-group {
    display: flex;
    gap: 8px;
    align-items: stretch; /* чтобы дочерние элементы растягивались по высоте */
}

.custom-country-select {
    position: relative;
    width: 100px; /* фиксированная ширина для селекта */
    flex-shrink: 0;
}

.select-selected {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    background: #fafafa;
    padding: 12px 10px; /* горизонтальный padding чуть меньше из-за флага */
    white-space: nowrap;
}

.select-selected .fi {
    width: 20px;
    height: 15px;
    border-radius: 2px;
}

.select-items {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid rgba(0, 183, 7, 0.15);
    border-radius: 10px;
    margin-top: 4px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.select-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background 0.2s;
}

.select-item:hover {
    background: rgba(0, 183, 7, 0.05);
}

.select-item.selected {
    background: rgba(0, 183, 7, 0.1);
    font-weight: 500;
}

.select-item .fi {
    width: 20px;
    height: 15px;
    border-radius: 2px;
}

/* Поле телефона */
.phone-group .popup-field {
    flex: 1;
}

/* Ошибки валидации */
.field-error {
    color: #e74c3c;
    font-size: 11px;
    margin-top: 2px;
    min-height: 14px;
}

/* Яндекс Капча */
.captcha-wrapper {
    margin-top: 5px;
}

.smart-captcha {
    min-height: 70px;
    border-radius: 10px;
    overflow: hidden;
}

.captcha-status {
    font-size: 11px;
    margin-top: 3px;
    color: #5a6b6f;
}

/* Блок согласий (два чекбокса) */
.form-agreements {
    margin: 12px 0 15px;
}

.agreement-item {
    margin-bottom: 6px;
}

.agreement-item .checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: #5a6b6f;
    cursor: pointer;
    line-height: 1.3;
}

.agreement-item .checkbox input {
    display: none;
}

.agreement-item .checkbox .checkmark {
    width: 16px;
    height: 16px;
    background: white;
    border: 1.5px solid rgba(0, 183, 7, 0.3);
    border-radius: 4px;
    position: relative;
    flex-shrink: 0;
    margin-top: 1px;
    transition: all 0.2s ease;
}

.agreement-item .checkbox input:checked + .checkmark {
    background: #00B707;
    border-color: #00B707;
}

.agreement-item .checkbox input:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.agreement-item .checkbox a {
    color: #00B707;
    text-decoration: none;
    transition: color 0.2s;
}

.agreement-item .checkbox a:hover {
    text-decoration: underline;
}

/* Кнопка отправки */
.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #00B707, #00B707);
    color: white;
    border: none;
    padding: 14px 16px; /* чуть меньше, чем было */
    border-radius: 10px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 183, 7, 0.2);
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 183, 7, 0.3);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    background: #bdc3c7;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Сообщения об успехе/ошибке */
.form-message {
    text-align: center;
    padding: 20px 10px;
}

.message-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.message-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #1a2e35;
}

.message-text {
    font-size: 14px;
    color: #5a6b6f;
}

.success-message .message-icon {
    color: #00B707;
}

.error-message .message-icon {
    color: #e74c3c;
}

/* Анимация закрытия */
.cta-modal.closing .cta-modal-container {
    animation: modalSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
}

/* Адаптивность */
@media (max-width: 600px) {
    .cta-modal {
        padding: 15px;
    }
    
    .cta-modal-container {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px;
    }
    
    .compact-form {
        padding: 20px 20px 15px;
    }
    
    .form-title {
        font-size: 20px;
    }
    
    .form-subtitle {
        font-size: 12px;
    }
    
    .popup-field,
    .select-selected {
        padding: 11px 12px;
        font-size: 14px;
    }
    
    .custom-country-select {
        width: 90px;
    }
    
    .submit-btn {
        padding: 12px 14px;
        font-size: 15px;
    }
}

@media (max-width: 400px) {
    .compact-form {
        padding: 15px 15px 12px;
    }
    
    .cta-modal-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .form-title {
        font-size: 18px;
    }
    
    .phone-group {
        flex-wrap: wrap;
    }
    
    .custom-country-select {
        width: 100%;
    }
}

/* Фикс для iOS */
@supports (-webkit-touch-callout: none) {
    .cta-modal-container {
        max-height: 90vh;
        -webkit-overflow-scrolling: touch;
    }
}