/* International Phone Input Styling */

/* Main container styling */
.iti {
    width: 100%;
    position: relative;
}

/* Input field styling to match Bootstrap form-control */
.iti__input {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Focus state */
.iti__input:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Invalid state to match Bootstrap is-invalid */
.iti__input.is-invalid,
.iti__input:invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.iti__input.is-invalid:focus,
.iti__input:invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* Country selection flag container */
.iti__flag-container {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    padding: 1px;
}

/* Selected flag button */
.iti__selected-flag {
    z-index: 4;
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 8px 0 6px;
    border-left: 1px solid #ced4da;
    border-radius: 0 0.375rem 0.375rem 0;
    background-color: #f8f9fa;
    transition: background-color 0.15s ease-in-out;
}

.iti__selected-flag:hover {
    background-color: #e9ecef;
}

/* Arrow icon */
.iti__arrow {
    margin-left: 6px;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid #6c757d;
}

.iti__arrow--up {
    border-top: none;
    border-bottom: 4px solid #6c757d;
}

/* Country dropdown */
.iti__country-list {
    position: absolute;
    z-index: 1050;
    list-style: none;
    text-align: left;
    padding: 0;
    margin: 0 0 0 -1px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background-color: white;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    white-space: nowrap;
    max-height: 200px;
    overflow-y: scroll;
    font-size: 0.875rem;
}

/* Country list items */
.iti__country {
    padding: 8px 12px;
    line-height: 1.4;
    color: #212529;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.iti__country:hover,
.iti__country.iti__highlight {
    background-color: #f8f9fa;
}

/* Preferred countries divider */
.iti__divider {
    padding-bottom: 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid #ced4da;
}

/* Flag icons */
.iti__flag {
    width: 20px;
    height: 15px;
    margin-right: 8px;
    background-image: url("https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/18.2.1/img/flags.png");
    background-repeat: no-repeat;
    background-color: #dbdbdb;
    background-position: 20px 0;
    display: inline-block;
    vertical-align: middle;
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .iti__flag {
        background-image: url("https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/18.2.1/img/flags@2x.png");
    }
}

/* Individual flag positions (key countries) */
.iti__flag.iti__in { background-position: -2420px 0; }
.iti__flag.iti__us { background-position: -5380px 0; }
.iti__flag.iti__gb { background-position: -2200px 0; }
.iti__flag.iti__ca { background-position: -520px 0; }
.iti__flag.iti__au { background-position: -220px 0; }

/* Country name and dial code */
.iti__country-name {
    margin-right: 6px;
    color: #212529;
}

.iti__dial-code {
    color: #6c757d;
    font-weight: 500;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .iti__country-list {
        max-height: 150px;
        font-size: 0.8rem;
    }
    
    .iti__country {
        padding: 6px 10px;
    }
    
    .iti__selected-flag {
        padding: 0 6px 0 4px;
    }
    
    .iti__flag {
        width: 16px;
        height: 12px;
        margin-right: 6px;
    }
}

/* Bootstrap form validation feedback compatibility */
.iti__input + .invalid-feedback {
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* Custom error styling for phone validation */
#invalid-phone-error {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* Loading state for country detection */
.iti__selected-flag.loading {
    background-color: #e9ecef;
    cursor: wait;
}

/* Hide default browser validation on tel inputs */
input[type="tel"]::-webkit-outer-spin-button,
input[type="tel"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="tel"] {
    -moz-appearance: textfield;
}