/* 
   Add this CSS to style the autocomplete functionality
   File: app/code/Tbi/CityAreaDropdown/view/frontend/web/css/autocomplete.css
*/

.autocomplete-container {
    position: relative;
    width: 100%;
}

.autocomplete-container input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #c2c2c2;
    font-size: 14px;
    line-height: 1.4;
    background-color: #fff;
    box-sizing: border-box;
}

.autocomplete-container input:focus {
    border-color: #007bdb;
    outline: none;
    box-shadow: 0 0 0 1px #007bdb;
}

.autocomplete-container input.loading {
    background-image: url('data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wjRLnSUZQwjJC5SkMhKgQgJRRNNPRmLxU8JxLSCGzGKCowRhpB5Lj4OaqtQwAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
    padding-right: 35px;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #c2c2c2;
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.autocomplete-option {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    transition: background-color 0.2s ease;
}

.autocomplete-option:last-child {
    border-bottom: none;
}

.autocomplete-option:hover,
.autocomplete-option.hover,
.autocomplete-option.selected {
    background-color: #f5f5f5;
}

.autocomplete-option.selected {
    background-color: #007bdb;
    color: white;
}

.autocomplete-option.custom-option {
    background-color: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    font-style: italic;
    color: #666;
}

.autocomplete-option.custom-option:hover {
    background-color: #e9e9e9;
}

.autocomplete-option strong {
    font-weight: 600;
    color: #007bdb;
}

.autocomplete-option.selected strong {
    color: white;
}

/* Checkout specific styles */
.checkout-container .autocomplete-container input {
    height: 32px;
    padding: 7px 8px;
    font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.checkout-container .autocomplete-container input.loading {
    padding-right: 30px;
    background-size: 14px 14px;
}

.checkout-container .autocomplete-dropdown {
    font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.checkout-container .autocomplete-option {
    padding: 8px 10px;
    font-size: 13px;
}

/* Error state */
.field._error .autocomplete-container input {
    border-color: #e22626;
}

/* Required field */
._required .autocomplete-container input {
    box-shadow: inset -1px 0 0 0 #df280a;
}

/* Loading animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.autocomplete-container input.loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bdb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .autocomplete-dropdown {
        max-height: 200px;
    }
    
    .autocomplete-option {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

.input-mode-selector {
    border-bottom: none !important;
}

.checkout-index-index .styledSelect {
    display: none !important;
}

/* Telephone Country Code Prefix Styles */

.country-code-prefix {
    position: absolute !important;
    left: 10px !important;
    top: 11px !important;
    bottom: auto !important;
    display: flex !important;
    align-items: center !important;
    font-weight: 600 !important;
    color: #333 !important;
    background: #f5f5f5 !important;
    padding: 0 12px !important;
    border-radius: 4px 0 0 4px !important;
    font-size: 14px !important;
    z-index: 10 !important;
    pointer-events: none !important;
    border-right: 1px solid #ddd !important;
    line-height: 1 !important;
    margin: 0 !important;
    height: auto !important;
}

[name="shippingAddress.telephone"] .control,
[name="billingAddress.telephone"] .control,
[name="shippingAddress.alternate_phone"] .control,
[name="billingAddress.alternate_phone"] .control,
[name="telephone"] .control {
    position: relative !important;
    display: block !important;
}

[name="shippingAddress.telephone"] input.input-text,
[name="billingAddress.telephone"] input.input-text,
[name="shippingAddress.alternate_phone"] input.input-text,
[name="billingAddress.alternate_phone"] input.input-text,
[name="telephone"] input.input-text {
    padding-left: 70px !important;
    position: relative !important;
}

[name="shippingAddress.telephone"]._error .control,
[name="billingAddress.telephone"]._error .control,
[name="shippingAddress.alternate_phone"]._error .control,
[name="billingAddress.alternate_phone"]._error .control,
[name="shippingAddress.telephone"].field-error .control,
[name="billingAddress.telephone"].field-error .control,
[name="shippingAddress.alternate_phone"].field-error .control,
[name="billingAddress.alternate_phone"].field-error .control,
[name="shippingAddress.telephone"].mage-error .control,
[name="billingAddress.telephone"].mage-error .control,
[name="shippingAddress.alternate_phone"].mage-error .control,
[name="billingAddress.alternate_phone"].mage-error .control {
    position: relative !important;
}

[name="shippingAddress.telephone"] .control .country-code-prefix,
[name="billingAddress.telephone"] .control .country-code-prefix,
[name="shippingAddress.alternate_phone"] .control .country-code-prefix,
[name="billingAddress.alternate_phone"] .control .country-code-prefix {
    top: 11px !important;
    bottom: auto !important;
    transform: none !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
}

[name="shippingAddress.telephone"] .control input.input-text,
[name="billingAddress.telephone"] .control input.input-text,
[name="shippingAddress.alternate_phone"] .control input.input-text,
[name="billingAddress.alternate_phone"] .control input.input-text {
    position: relative !important;
    z-index: 1 !important;
}

[name="shippingAddress.telephone"]:not(:has(.country-code-prefix)) input.input-text,
[name="billingAddress.telephone"]:not(:has(.country-code-prefix)) input.input-text,
[name="shippingAddress.alternate_phone"]:not(:has(.country-code-prefix)) input.input-text,
[name="billingAddress.alternate_phone"]:not(:has(.country-code-prefix)) input.input-text {
    padding-left: 10px !important;
}

.telephone .field-note,
[name="shippingAddress.telephone"] .field-note,
[name="billingAddress.telephone"] .field-note,
[name="shippingAddress.alternate_phone"] .field-note,
[name="billingAddress.alternate_phone"] .field-note {
    color: #999 !important;
    font-style: italic !important;
    font-size: 1.2rem !important;
    margin-top: 5px !important;
    display: block !important;
}