/* Province and District Fields Styling - Loaded Successfully */

/* Test rule to verify CSS is loaded */
body.woocommerce-checkout {
    --checkout-district-css-loaded: true;
}

#billing_state_field,
#shipping_state_field,
#billing_district_field,
#shipping_district_field {
    margin-bottom: 42px;
}

/* Style province fields to match other checkout fields */
#billing_state_field label,
#shipping_state_field label,
#billing_district_field label,
#shipping_district_field label {
    display: inline-block;
    font-size: 15px;
    left: 0;
    line-height: 20px;
    position: absolute;
    top: calc(50% - 20px);
    -webkit-transition: top 0.3s ease-in-out 0s;
    transition: top 0.3s ease-in-out 0s;
}

/* Focusing state for labels */
#billing_state_field.focusing label,
#shipping_state_field.focusing label,
#billing_district_field.focusing label,
#shipping_district_field.focusing label {
    top: -20px;
    font-family: "iCiel Campton";
    font-style: normal;
    font-weight: 400;
    font-size: 12px;
    line-height: 140.3%;
    color: #000;
}

/* Ensure state fields have proper positioning */
#billing_state_field.plabel,
#shipping_state_field.plabel,
#billing_district_field.plabel,
#shipping_district_field.plabel {
    position: relative;
}

#billing_state,
#shipping_state,
#billing_district,
#shipping_district,
.state_select {
    width: 100%;
    padding: 12px 5px;
    border: 0;
    border-bottom: 1px solid #000;
    background-color: #f2f2f2;
}

/* Style for select options */
.state_select *,
#billing_state option,
#shipping_state option,
#billing_district option,
#shipping_district option,
select option {
    padding: 10px 15px;
    background-color: #f2f2f2;
    color: #333;
    border: none;
    font-size: 14px;
    line-height: 1.4;
}

.state_select *:hover,
#billing_state option:hover,
#shipping_state option:hover,
#billing_district option:hover,
#shipping_district option:hover,
select option:hover {
    background-color: #f8f8f8;
    color: #000;
}

/* Selected state for native select options */
#billing_state option:selected,
#shipping_state option:selected,
#billing_district option:selected,
#shipping_district option:selected,
select option:selected {
    background-color: #ededed;
    color: #000;
}

/* Style for Select2 dropdown options */
.select2-container--default .select2-results__option {
    padding: 10px 15px;
    background-color: #f2f2f2;
    color: #333;
    border: 0;
    border-bottom: 1px solid #000;
}

.select2-container--default .select2-results__option:hover {
    background-color: #f8f8f8;
    color: #000;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #ededed;
    color: #000;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #ededed;
    color: #000;
}

/* Style for Select2 dropdown container */
.select2-container--default .select2-dropdown {
    border: 1px solid #000;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background-color: #f2f2f2;
}

/* Style for Select2 selection */
.select2-container--default .select2-selection--single {
    height: auto;
    border: 0;
    border-bottom: 1px solid #000;
    background-color: #f2f2f2;
    border-radius: 0;
}

/* Ensure all select fields have consistent styling */
.shipping_state select,
.billing_state select {
    width: 100%;
    padding: 12px 5px;
    border: 0;
    border-bottom: 1px solid #000;
    background-color: #f2f2f2;
    font-size: 14px;
    color: #333;
    border-radius: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Specific styling for country fields to match state fields */
#billing_country,
#shipping_country {
    width: 100%;
    padding: 12px 5px;
    border: 0;
    border-bottom: 1px solid #000;
    background-color: #f2f2f2;
    font-size: 14px;
    color: #333;
    border-radius: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 40px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding: 0;
    line-height: 22px;
    color: #333;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
    top: 0;
    right: 10px;
}

/* Focus states for better UX */
#billing_state:focus,
#shipping_state:focus,
#billing_district:focus,
#shipping_district:focus,
.state_select:focus,
select:focus,
.select2-container--default.select2-container--focus .select2-selection--single {
    outline: none;
}

/* Placeholder styling */
#billing_state option[value=""],
#shipping_state option[value=""],
#billing_district option[value=""],
#shipping_district option[value=""],
.state_select option[value=""] {
    color: #999;
    font-style: italic;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    #billing_state,
    #shipping_state,
    #billing_district,
    #shipping_district,
    .state_select,
    select,
    .select2-container--default .select2-selection--single {
        padding: 10px 5px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .select2-container--default .select2-results__option {
        padding: 12px 15px;
        font-size: 16px;
    }
}





#billing_state.input_error,
#shipping_state.input_error,
#billing_district.input_error,
#shipping_district.input_error {
    border-color: #dc3232;
}

#billing_state.input_valid,
#shipping_state.input_valid,
#billing_district.input_valid,
#shipping_district.input_valid {
    border-color: #7ad03a;
}



/* Loading state for district select */
.district-loading {
    opacity: 0.6;
    pointer-events: none;
}

.district-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #billing_district_field,
    #shipping_district_field {
        margin-bottom: 15px;
    }
    
    #billing_district,
    #shipping_district {
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Select2 integration for search functionality */
.select2-container--default .select2-selection--single {
    height: 45px;
    border: 0;
    border-bottom: 1px solid #000;
    border-radius: 0;
    background-color: #f2f2f2;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 43px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 43px;
}


.select2-container--default .select2-dropdown {
    border: 1px solid #000;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1060; /* Higher than modals (1050) but lower than tooltips (1070) */
}

/* Specific z-index for Vietnam province/district dropdowns */
#billing_state_field .select2-dropdown,
#shipping_state_field .select2-dropdown,
#billing_city_field .select2-dropdown,
#shipping_city_field .select2-dropdown {
    z-index: 1060;
}

/* Ensure Select2 containers don't conflict with other elements */
.select2-container.select2-border-container {
    z-index: auto;
}

/* Style Vietnam state Select2 to match other countries */
#billing_state_field .select2-container,
#shipping_state_field .select2-container,
#billing_city_field .select2-container,
#shipping_city_field .select2-container {
    width: 100% !important;
}

#billing_state_field .select2-selection,
#shipping_state_field .select2-selection,
#billing_city_field .select2-selection,
#shipping_city_field .select2-selection {
    height: 45px !important;
    border: 0;
    border-bottom: 1px solid #000;
    border-radius: 0;
}

#billing_state_field .select2-selection__rendered,
#shipping_state_field .select2-selection__rendered,
#billing_city_field .select2-selection__rendered,
#shipping_city_field .select2-selection__rendered {
    padding: 0 8px !important;
    line-height: 43px !important;
}

.select2-dropdown.select2-border-dropdown {
    z-index: 1060;
    /* Ensure dropdown is visible and not clipped */
    max-height: 300px;
    overflow-y: auto;
}

/* Ensure dropdown appears above other elements in checkout form */
.checkout .select2-dropdown {
    z-index: 1060 !important;
}

/* Specific positioning for Vietnam select dropdowns */
.checkout #billing_state_field .select2-dropdown,
.checkout #shipping_state_field .select2-dropdown,
.checkout #billing_city_field .select2-dropdown,
.checkout #shipping_city_field .select2-dropdown {
    z-index: 1060 !important;
    position: absolute !important;
}

/* Ensure dropdown is not hidden behind sticky cart or other elements */
.checkout .select2-container--open .select2-dropdown {
    z-index: 1060 !important;
}

/* Handle mobile responsive dropdowns */
@media (max-width: 768px) {
    .select2-dropdown.select2-border-dropdown {
        max-height: 250px;
        width: 100% !important;
    }
}

.select2-container .select2-search--dropdown {
    padding: 5px 14px 5px 5px !important;
}
.select2-container .select2-search--dropdown .select2-search__field {
    height: 35px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #000;
    border-radius: 4px;
    padding: 8px 12px;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    outline: none;
}

.select2-container--default .select2-results__options li.select2-results__option {
    margin: 8px 6px;
    padding: 10px;
    border: 0;
    border-bottom: 1px solid #000;
}


/* Loading state for Select2 */
.select2-container--default.select2-container--loading .select2-selection--single {
    opacity: 0.6;
}

/* Responsive Select2 */
@media (max-width: 768px) {
    .select2-container--default .select2-selection--single {
        height: 50px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 48px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 48px;
    }
}

/* Validation Messages */
.validation-message {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.4;
}

.validation-message.error {
    color: #dc3232;
}

.validation-message.success {
    color: #7ad03a;
}

/* Vietnam-specific styles */

.vn-field {
    background-color: #f8f9fa;
}

/* Required field indicator */
.form-row.validate-required label .required {
    color: #dc3232;
    font-weight: bold;
} 

.select2-container--default .select2-results__option[aria-selected=true], .select2-container--default .select2-results__option[data-selected=true] {
    background-color: #ededed !important;
    color: #000;
}