.waa-phone-prefix-wrap {
    display: flex !important;
    align-items: center;
    position: relative;
    width: 100%;
    border: 1px solid currentColor;
    box-sizing: border-box;
}

.waa-phone-country-holder {
    position: relative;
    display: inline-flex;
    align-items: center;
    align-self: stretch;
    min-width: 62px;
    border-right: 1px solid currentColor;
    box-sizing: border-box;
}

.waa-phone-flag {
    display: flex;
    align-items: center;
    padding: 0 5px;
    background: transparent;
}

.waa-phone-flag:empty,
.waa-phone-prefix:empty {
    display: none;
}

.waa-phone-flag img {
    display: block !important;
    width: 30px !important;
    max-width: 30px !important;
    height: auto !important;
}

.waa-phone-prefix {
    flex: 0 0 auto;
    padding: 0 5px;
    color: #555;
}

.waa-phone-prefix-wrap input[type="tel"] {
    display: block !important;
    flex: 1 1 auto !important;
    width: 1% !important;
    min-width: 0 !important;
    padding-left: 6px !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.waa-phone-country-search-button {
    position: relative;
    z-index: 2;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: #777 !important;
    cursor: pointer !important;
    flex: 0 0 30px;
    text-align: center !important;
}

.waa-phone-country-search-button:hover,
.waa-phone-country-search-button:focus {
    color: #333 !important;
}

.waa-phone-country-search-button svg {
    display: block;
    width: 20px;
    height: 20px;
    margin: auto;
}

/*
 * Keep the native select functional until SelectWoo has initialized it.
 * The previous integration hid the select unconditionally, so any delayed or
 * failed SelectWoo initialization left no usable control at all.
 */
.waa-phone-country-select:not(.select2-hidden-accessible) {
    position: absolute !important;
    inset: 0 !important;
    z-index: 4 !important;
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0.01 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* SelectWoo creates this container directly after the native select. It is an
 * invisible click target over the search icon and flag, just as in the original
 * phone-validation plugin, but without contradictory width rules. */
.waa-phone-country-holder .select2-container.waa-phone-country-trigger {
    position: absolute !important;
    inset: 0 !important;
    z-index: 5 !important;
    display: block !important;
    width: 100% !important;
    min-width: 30px !important;
    max-width: none !important;
    margin: 0 !important;
    opacity: 0.01 !important;
    overflow: visible !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

.waa-phone-country-holder .select2-container.waa-phone-country-trigger .selection,
.waa-phone-country-holder .select2-container.waa-phone-country-trigger .select2-selection--single {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
}

.waa-phone-country-holder .select2-container.waa-phone-country-trigger .select2-selection__rendered,
.waa-phone-country-holder .select2-container.waa-phone-country-trigger .select2-selection__arrow {
    display: none !important;
}

/* A native fallback remains clickable if SelectWoo cannot initialize. */
.waa-phone-country-select.waa-phone-country-native-fallback {
    opacity: 0.01 !important;
    pointer-events: auto !important;
}

body > .select2-container--open,
.select2-container--open {
    z-index: 999999 !important;
}

.select2-container--open.waa-phone-country-open-container {
    box-sizing: border-box !important;
}

.select2-container--open .select2-dropdown,
.select2-dropdown.waa-phone-country-dropdown {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    border-top: 1px solid #aaa !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
}

.waa-phone-country-dropdown .select2-search--dropdown,
.select2-container--open .select2-search--dropdown {
    display: block !important;
    visibility: visible !important;
    padding: 8px !important;
}

.waa-phone-country-dropdown .select2-search__field,
.select2-container--open .select2-search__field {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 6px 10px !important;
    color: #222 !important;
    background: #fff !important;
    border: 1px solid #aaa !important;
    border-radius: 2px !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}

.waa-phone-country-dropdown .select2-results__options,
.select2-container--open .select2-results__options {
    max-height: 300px !important;
    overflow-y: auto !important;
}

.waa-phone-country-result {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    width: 100%;
}

.waa-phone-country-result img {
    display: block !important;
    width: 24px !important;
    max-width: 24px !important;
    height: auto !important;
}

.waa-phone-country-result-name {
    overflow: hidden;
    min-width: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.waa-phone-validation-error {
    display: block;
    clear: both;
    width: 100%;
    margin-top: 5px;
    color: #b81c23;
    font-size: 0.9em;
}

.form-row.processing .waa-phone-prefix-wrap::after {
    content: "";
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: waa-phone-spin 0.7s linear infinite;
}

@keyframes waa-phone-spin {
    to { transform: rotate(360deg); }
}

.waa-phone-country-holder-selectable .waa-phone-flag {
    cursor: pointer;
}

@media (max-width: 480px) {
    .waa-phone-country-result {
        grid-template-columns: 26px minmax(0, 1fr);
    }
}
