/**
 * Кастомные стили для intl-tel-input
 * Адаптация под дизайн сайта nomad.how2spain.com
 */

/* Основной контейнер */
.iti {
    width: 100%;
    position: relative;
}

/* Поле ввода */
.iti input[type="tel"] {
    width: 100% !important;
    padding-left: 52px !important;
    padding-right: 6px !important;
    border: 1px solid #ddd;
    border-radius: 30px;
    font-size: 16px;
    line-height: 1.5;
    transition: border-color 0.3s ease;
}

.iti input[type="tel"]:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Контейнер флага */
.iti__flag-container {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 2;
    padding: 1px;
}

/* Выбранный флаг */
.iti__selected-flag {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 8px;
    cursor: pointer;
    border-radius: 30px 0 0 30px;
    transition: background-color 0.3s ease;
}

.iti__selected-flag:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Флаг */
.iti__flag {
    width: 20px;
    height: 15px;
    background-size: 5652px 15px;
    background-repeat: no-repeat;
    background-position: 0 0;
}

/* Стрелка выпадающего списка */
.iti__arrow {
    margin-left: 6px;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid #555;
    transition: transform 0.3s ease;
}

.iti__arrow--up {
    border-top: none;
    border-bottom: 4px solid #555;
    transform: rotate(180deg);
}

/* Выпадающий список стран */
.iti__country-list {
    position: absolute;
    z-index: 1000;
    list-style: none;
    text-align: left;
    padding: 0;
    margin: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    white-space: nowrap;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    width: auto;
    min-width: 300px;
}

.iti__country-list--dropup {
    bottom: 100%;
    margin-bottom: -1px;
}

/* Элемент страны */
.iti__country {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
}

.iti__country:hover,
.iti__country.iti__highlight {
    background-color: rgba(0, 123, 255, 0.1);
}

/* Флаг в списке */
.iti__flag-box {
    display: inline-block;
    width: 20px;
    margin-right: 8px;
}

/* Название страны */
.iti__country-name {
    margin-right: 8px;
    color: #999;
}

/* Код страны */
.iti__dial-code {
    color: #666;
    font-weight: 500;
}

/* Разделитель */
.iti__divider {
    padding: 8px 12px 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid #eee;
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Активная страна */
.iti__country.iti__active {
    background-color: rgba(0, 123, 255, 0.15);
    font-weight: 500;
}

/* Ошибка валидации */
.phone-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25) !important;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 500px) {
    .iti__country-list {
        white-space: normal;
        max-height: 150px;
    }
    
    .iti__country {
        padding: 6px 10px;
    }
    
    .iti input[type="tel"] {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
}

/* Стили для форм в попапах */
.popup .iti input[type="tel"] {
    border-radius: 33px;
    border: 1px solid #a3a3a3;
    padding: 12px 6px 12px 52px;
    width: 100% !important;
    min-width: 100%
}

/* Стили для форм в квизе */
.quiz .iti input[type="tel"] {
    border-radius: 25px;
    padding: 12px 6px 12px 52px;
    width: auto !important;
    min-width: 180px;
}

/* Стили для обычных форм */
.form .iti input[type="tel"] {
    border-radius: 33px;
    border: 1px solid #a3a3a3;
    padding: 12px 6px 12px 52px;
    width: 100% !important;
    min-width: 100%;
}

/* Темная тема (если понадобится) */
@media (prefers-color-scheme: dark) {
    .iti__country-list {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .iti__country:hover,
    .iti__country.iti__highlight {
        background-color: rgba(66, 153, 225, 0.2);
    }
    
    .iti__divider {
        border-bottom-color: #4a5568;
        color: #a0aec0;
    }
    
    .iti__dial-code {
        color: #a0aec0;
    }
}

/* Анимации */
.iti__country-list {
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Скрытие элементов при загрузке */
.iti__hide {
    display: none !important;
}

/* Улучшенная доступность */
.iti__selected-flag:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.iti__country:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}
