/**
 * Phone Country Support Styling
 * 
 * Custom styles for intl-tel-input library to match the WPResidence theme design.
 * 
 * @package WpResidence_Child
 * @since 1.0.0
 */

/* ==========================================================================
   International Telephone Input Styling
   ========================================================================== */

/* Container styling */
.iti {
    display: block !important;
    width: 100% !important;
}

/* Input field styling to match theme */
.iti__input,
.iti.iti input[type="text"],
.iti.iti input[type="tel"] {
    width: 100% !important;
    padding-left: 52px !important; /* Space for flag */
    height: auto !important;
    min-height: 42px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    transition: border-color 0.2s ease !important;
}

/* Input focus state */
.iti.iti input[type="text"]:focus,
.iti.iti input[type="tel"]:focus {
    border-color: #00a8ff !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(0, 168, 255, 0.1) !important;
}

/* Flag container */
.iti__flag-container {
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 52px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Selected flag button */
.iti__selected-flag {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 8px !important;
    height: 100% !important;
    background-color: #f8f8f8 !important;
    border-right: 1px solid #e0e0e0 !important;
    border-radius: 4px 0 0 4px !important;
    transition: background-color 0.2s ease !important;
}

.iti__selected-flag:hover {
    background-color: #ebebeb !important;
}

.iti__selected-flag:focus {
    outline: none !important;
    background-color: #e3e3e3 !important;
}

/* Dial code */
.iti__selected-dial-code {
    margin-left: 4px !important;
    font-size: 13px !important;
    color: #666 !important;
}

/* Arrow icon */
.iti__arrow {
    margin-left: 4px !important;
    border-left: 3px solid transparent !important;
    border-right: 3px solid transparent !important;
    border-top: 4px solid #666 !important;
}

.iti__arrow--up {
    border-top: none !important;
    border-bottom: 4px solid #666 !important;
}

/* Country dropdown */
.iti__country-list {
    max-height: 200px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    margin-top: 4px !important;
}

/* Country list items */
.iti__country {
    padding: 8px 12px !important;
    font-size: 14px !important;
    transition: background-color 0.15s ease !important;
}

.iti__country:hover {
    background-color: #f5f5f5 !important;
}

.iti__country.iti__highlight {
    background-color: #e8f4ff !important;
}

.iti__country.iti__active {
    background-color: #00a8ff !important;
    color: #fff !important;
}

/* Country name and dial code in dropdown */
.iti__country-name,
.iti__dial-code {
    font-size: 13px !important;
}

.iti__dial-code {
    color: #999 !important;
}

.iti__country.iti__active .iti__dial-code {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Search box in dropdown */
.iti__search-input {
    padding: 8px 12px !important;
    border: none !important;
    border-bottom: 1px solid #e0e0e0 !important;
    font-size: 14px !important;
}

.iti__search-input:focus {
    outline: none !important;
    border-bottom-color: #00a8ff !important;
}

/* Error state */
.phone-error {
    border-color: #d32f2f !important;
}

.phone-error:focus {
    border-color: #d32f2f !important;
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.1) !important;
}

.phone-error-message {
    color: #d32f2f !important;
    font-size: 12px !important;
    margin-top: 5px !important;
    display: block !important;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .iti__country-list {
        max-width: 100% !important;
    }

    .iti.iti input[type="text"],
    .iti.iti input[type="tel"] {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
}

/* RTL Support */
.rtl .iti__input {
    padding-left: 0 !important;
    padding-right: 52px !important;
}

.rtl .iti__flag-container {
    left: auto !important;
    right: 0 !important;
}

.rtl .iti__selected-flag {
    border-right: none !important;
    border-left: 1px solid #e0e0e0 !important;
    border-radius: 0 4px 4px 0 !important;
}

/* Ensure compatibility with WPResidence theme forms */
.contact_form_flex_input_wrapper .iti {
    margin-bottom: 0 !important;
}

.wpestate_contact_form_parent .iti {
    margin-bottom: 15px !important;
}

/* Dropdown positioning fix for modals */
.modal .iti__country-list {
    z-index: 10001 !important;
}

/* Fix for Elementor forms */
.elementor-field-type-text .iti,
.elementor-field-type-tel .iti {
    width: 100% !important;
}

/* Accessibility improvements */
.iti__country:focus {
    outline: 2px solid #00a8ff !important;
    outline-offset: -2px !important;
}

.iti__selected-flag:focus {
    outline: 2px solid #00a8ff !important;
    outline-offset: -2px !important;
}

/* Loading state */
.iti.iti--loading {
    opacity: 0.6 !important;
    pointer-events: none !important;
}
