/* Header currency dropdown with country/region flags.
   Progressive enhancement: the native <select id="currencySelect"> stays in the page and keeps
   doing the real work (cookie, reload / form resubmit). Until currency-selector.js adds
   .is-enhanced, the plain select is shown and the flag dropdown is hidden. */

header .currency-switcher { position: relative; }

.currency-flag-dropdown { display: none; }

header .currency-switcher.is-enhanced > #currencySelect { display: none; }
header .currency-switcher.is-enhanced > .currency-flag-dropdown { display: block; position: relative; }

/* The button reuses Bootstrap's .form-select look and the existing header .currency-switcher .form-select rules. */
header .currency-switcher { flex: 0 0 auto; }

header .currency-switcher .currency-flag-button {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    box-sizing: border-box;
    /* Fixed width (see the breakpoints below) so the control never resizes with the selected code. */
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    /* A <button> has no native arrow, and site.css's global .form-select replaces Bootstrap's arrow with an
       invalid image URL (data/svg+xml, missing ":image"). Redraw the same chevron here, scoped to this button only. */
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 16px 12px;
}

/* Desktop (the site's phone/tablet layout starts at 992px and below): room for flag + code on the left, arrow on the right. */
@media (min-width: 993px) {
    header .currency-switcher .currency-flag-button {
        padding-left: 10px;
        padding-right: 30px;
        background-position: right 8px center;
    }
}

.currency-flag-code { flex: 0 0 auto; }

.currency-flag {
    width: 20px;
    height: 15px;
    flex: 0 0 auto;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.currency-flag-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1100;
    min-width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem 0;
    list-style: none;
    background: #fff;
    color: #212529;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.75rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.currency-flag-menu[hidden] { display: none; }

.currency-flag-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

    .currency-flag-option:hover,
    .currency-flag-option:focus {
        background: #e9f2fb;
        outline: none;
    }

    .currency-flag-option[aria-selected="true"] { background: #d6e6f7; }

/* Phones and tablets: site.css supplies padding, font size and arrow position; only the fixed width is set here. */
@media (max-width: 992px) {
    header .currency-switcher .currency-flag-button {
        gap: 0.3rem;
        width: 100px;
        min-width: 100px;
        max-width: 100px;
    }
    .currency-flag { width: 18px; height: 13.5px; }
}

@media (max-width: 380px) {
    header .currency-switcher .currency-flag-button {
        width: 92px;
        min-width: 92px;
        max-width: 92px;
    }
}
