/* AU Country Code Select — shared styling for the country-code dropdown used on every form site-wide.
   Verified against an isolated replica of this site's exact Bootstrap 4 / bootstrap-select 1.13 stack
   before being ported here: see conversation history for the test page. */

.country-mobile-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    /* The Mobile input carries its own mb-3/mb-sm-4 spacing utility classes (for the gap before
       the next form row). Flex items don't let a child's margin collapse out of them, so that
       margin would otherwise be counted as part of the input's own box height, making it taller
       than its visible border and throwing off the stretch-match below. Cancelled on the input
       and reapplied here instead, so the row's total height (visible field + gap) is unchanged. */
    margin-bottom: 24px;
}

.country-mobile-row .col-mobile-code {
    display: flex;
    align-items: stretch;
    flex: 0 0 36%;
    max-width: 36%;
    min-width: 108px;
    padding-right: 10px;
}

.country-mobile-row .col-mobile-number {
    flex: 1 1 auto;
    max-width: 64%;
    padding-left: 0;
}

.country-mobile-row .col-mobile-number input {
    width: 100%;
    margin-bottom: 0 !important;
}

.country-mobile-row .bootstrap-select.country-code-select {
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box !important;
    /* bootstrap-select copies the <select>'s own classes onto this wrapper div — including the
       py-2/mb-3-style spacing classes every template passes in (needed for the plain <select>
       before enhancement). On the wrapper itself that adds unwanted padding/margin, pushing the
       visible button down relative to the Mobile input next to it, which has no such wrapper.
       Reset it here so every template gets correct alignment without editing each one. */
    padding: 0 !important;
    margin: 0 !important;
}

/* bootstrap-select's own CSS already gives .dropdown-toggle the correct layout for this
   (position:relative, display:inline-flex, justify-content:space-between) and positions .caret
   with position:absolute;right:12px — left untouched here on purpose. Overriding those structural
   rules previously made the caret compete with the text for space and overlap it. Only the visual
   properties (colors/border/padding) are customized below. */
.country-mobile-row .bootstrap-select.country-code-select > .dropdown-toggle {
    width: 100%;
    /* Same native arrow Bootstrap's .custom-select uses (e.g. the Country/State field) — reused
       here instead of a hand-built caret element, for guaranteed pixel-identical appearance. */
    background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right 0.75rem center !important;
    background-size: 8px 10px !important;
    border: 1px solid #ced4da !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 10px 28px 10px 10px !important;
    height: 100% !important;
    box-sizing: border-box !important;
    color: #495057 !important;
}

.country-mobile-row .bootstrap-select.country-code-select > .dropdown-toggle:focus,
.country-mobile-row .bootstrap-select.country-code-select > .dropdown-toggle:active {
    outline: none !important;
    box-shadow: none !important;
}

/* Both of bootstrap-select's native carets proved unreliable across contexts (the library's own
   absolutely-positioned ".caret" could escape the button's bounds in some pages; Bootstrap 4's
   .dropdown-toggle::after drew a second one on top of it). Both are hidden here entirely — the
   arrow shown is the background-image set on .dropdown-toggle above instead. */
.country-mobile-row .bootstrap-select.country-code-select > .dropdown-toggle::after {
    display: none !important;
    content: none !important;
}

.country-mobile-row .bootstrap-select.country-code-select .caret {
    display: none !important;
}

.country-mobile-row .bootstrap-select .filter-option {
    overflow: hidden;
    /* bootstrap-select's own CSS reserves right padding here for its native caret, which is
       hidden above in favor of our own inline one — reclaim that space, or the flag/text/caret
       get squeezed into a far narrower box than actually available and clip. */
    padding-right: 0 !important;
}

.country-mobile-row .bootstrap-select .filter-option-inner,
.country-mobile-row .bootstrap-select .filter-option-inner-inner {
    overflow: hidden;
    white-space: nowrap;
    max-width: 100%;
    padding-right: 0 !important;
    display: flex !important;
    align-items: center !important;
    font-size: 15px;
}

.country-code-flag {
    display: inline-block !important;
    position: relative !important;
    box-sizing: border-box !important;
    width: 24px !important;
    height: 18px !important;
    min-width: 24px !important;
    max-width: 24px !important;
    margin: 0 8px 0 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: 50% !important;
    vertical-align: middle !important;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, .12);
    background-color: #eee;
}

.country-code-flag::before {
    content: "" !important;
}

.au-code-compact {
    font-weight: 500;
}

/* The dropdown panel stays in its normal nested position (no container:'body' relocation) —
   bootstrap-select's own default Popper-based positioning handles the modal case correctly once
   nothing is overriding its native .dropdown-toggle/.caret layout (see above). */
.bootstrap-select.country-code-select .dropdown-menu {
    z-index: 2000;
    min-width: 270px;
    max-width: 310px;
}

.bootstrap-select.country-code-select .bs-searchbox {
    padding: 8px;
}

.bootstrap-select.country-code-select .bs-searchbox input.form-control {
    height: auto;
    padding: 7px 10px;
    font-size: 14px;
}

.bootstrap-select.country-code-select .dropdown-menu li a {
    display: flex;
    align-items: center;
    white-space: normal;
    padding: 7px 12px;
}

.bootstrap-select.country-code-select .dropdown-menu li a .country-code-flag {
    margin-right: 8px;
}

@media (max-width: 575px) {
    .country-mobile-row {
        margin-bottom: 16px;
    }

    .country-mobile-row .col-mobile-code {
        flex: 0 0 38%;
        max-width: 38%;
    }

    .country-mobile-row .col-mobile-number {
        flex: 1 1 auto;
        max-width: 62%;
    }

    .bootstrap-select.country-code-select .dropdown-menu {
        min-width: 230px;
        max-width: 270px;
    }
}
