:root {
    --location-select-accent: #4fe0c0;
    --location-select-bg: #061822;
    --location-select-bg-alt: #071923;
    --location-select-search-bg: #05151f;
    --location-select-border: #31586a;
    --location-select-divider: #234556;
    --location-select-text: #f1fbff;
    --location-select-muted: #7994a3;
    --location-select-option: #b9d5df;
    --location-select-radius: 10px;
    --location-select-height: 44px;
}

/* Las demos heredan su identidad visual configurada desde la administración. */
body.location-storefront-demo {
    --location-select-accent: var(--primary, #4fe0c0);
    --location-select-bg: color-mix(in srgb, var(--bg, #03040b) 76%, transparent);
    --location-select-bg-alt: color-mix(in srgb, var(--bg-2, #0a0f1e) 92%, #000);
    --location-select-search-bg: color-mix(in srgb, var(--bg, #03040b) 90%, #000);
    --location-select-border: var(--line, rgba(255, 255, 255, .12));
    --location-select-divider: color-mix(in srgb, var(--line, rgba(255, 255, 255, .12)) 86%, transparent);
    --location-select-text: var(--text, #fff);
    --location-select-muted: var(--muted, #8d99b4);
    --location-select-option: var(--soft, #c8d2e7);
    --location-select-radius: 15px;
    --location-select-height: 45px;
}

/* La plantilla maestra usa exactamente la paleta administrable de la tienda. */
body[data-store-theme] {
    --location-select-accent: var(--store-custom-link, var(--orange, #4fe0c0));
    --location-select-bg: var(--store-custom-surface-alt, #071923);
    --location-select-bg-alt: var(--store-custom-surface, #102331);
    --location-select-search-bg: var(--store-custom-surface-alt, #071923);
    --location-select-border: var(--store-custom-border, #31586a);
    --location-select-divider: var(--store-custom-border, #234556);
    --location-select-text: var(--store-custom-text, #f1fbff);
    --location-select-muted: var(--store-custom-muted, #7994a3);
    --location-select-option: var(--store-custom-text, #f1fbff);
    --location-select-radius: min(var(--store-custom-radius, 12px), 16px);
    --location-select-height: 46px;
}

/* El demo de restaurante utiliza una superficie clara. */
body.theme-polleria-menu.location-storefront-demo {
    --location-select-bg: #fffdf9;
    --location-select-bg-alt: #fffaf0;
    --location-select-search-bg: #fffdf9;
    --location-select-border: rgba(228, 87, 18, .22);
    --location-select-divider: rgba(228, 87, 18, .16);
    --location-select-text: #351505;
    --location-select-muted: #9b6845;
    --location-select-option: #6f3a19;
    --location-select-radius: 16px;
    --location-select-height: 48px;
}

.location-select-field {
    min-width: 0;
}

#cartDrawer,
#cartDrawer .drawer-body,
#cartDrawer .checkout-step,
#cartDrawer .field,
#cartDrawer .grid2 > * {
    min-width: 0;
}

#cartDrawer select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#cartDrawer .select2-container {
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
}

.location-select-field > label {
    display: block;
}

.location-select + .select2-container {
    width: 100% !important;
    margin: 5px 0 11px;
    font: inherit;
}

.location-select + .select2-container .select2-selection--single {
    height: var(--location-select-height);
    overflow: hidden;
    border: 1px solid var(--location-select-border);
    border-radius: var(--location-select-radius);
    background: var(--location-select-bg);
    box-shadow: none;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

body.theme-polleria-menu .location-select + .select2-container .select2-selection--single {
    border-width: 2px;
    box-shadow: inset 0 -2px 0 rgba(75, 29, 8, .03);
}

.location-select + .select2-container .select2-selection__rendered {
    max-width: 100%;
    overflow: hidden;
    padding: 0 48px 0 13px;
    color: var(--location-select-text);
    line-height: calc(var(--location-select-height) - 2px);
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.theme-polleria-menu .location-select + .select2-container .select2-selection__rendered {
    line-height: calc(var(--location-select-height) - 4px);
}

.location-select + .select2-container .select2-selection__placeholder {
    color: var(--location-select-muted);
}

.location-select + .select2-container .select2-selection__arrow {
    width: 42px;
    height: calc(var(--location-select-height) - 2px);
    border-left: 1px solid var(--location-select-divider);
}

.location-select + .select2-container .select2-selection__arrow b {
    width: 7px;
    height: 7px;
    margin: -5px 0 0 -4px;
    border: 0;
    border-right: 2px solid var(--location-select-accent);
    border-bottom: 2px solid var(--location-select-accent);
    transform: rotate(45deg);
    transition: transform .18s ease;
}

.location-select + .select2-container.select2-container--open .select2-selection__arrow b {
    margin-top: -1px;
    transform: rotate(225deg);
}

.location-select + .select2-container.select2-container--focus .select2-selection--single,
.location-select + .select2-container.select2-container--open .select2-selection--single {
    border-color: var(--location-select-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--location-select-accent) 14%, transparent);
}

.location-select.is-invalid + .select2-container .select2-selection--single {
    border-color: var(--danger, #ff5c7a) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger, #ff5c7a) 15%, transparent) !important;
}

.location-select + .select2-container.select2-container--disabled .select2-selection--single {
    cursor: not-allowed;
    opacity: .55;
}

.location-select-dropdown.select2-dropdown {
    z-index: 5000;
    width: 100%;
    max-width: calc(100vw - 16px);
    overflow: hidden;
    margin-top: 5px;
    border: 1px solid var(--location-select-border);
    border-radius: var(--location-select-radius);
    background: var(--location-select-bg-alt);
    color: var(--location-select-text);
    box-shadow: 0 20px 48px rgba(0, 0, 0, .38);
}

.location-select-dropdown.select2-dropdown--above {
    margin-top: -5px;
    margin-bottom: 5px;
}

.location-select-dropdown .select2-search--dropdown {
    padding: 10px;
    border-bottom: 1px solid var(--location-select-divider);
    background: var(--location-select-bg-alt);
}

.select2-container--default .location-select-dropdown .select2-search--dropdown .select2-search__field {
    height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--location-select-border);
    border-radius: calc(var(--location-select-radius) * .72);
    background: var(--location-select-search-bg);
    color: var(--location-select-text);
    font: inherit;
    outline: 0;
}

.select2-container--default .location-select-dropdown .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--location-select-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--location-select-accent) 13%, transparent);
}

.location-select-dropdown .select2-results__options {
    max-height: 270px !important;
    padding: 6px;
    background: var(--location-select-bg-alt);
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.select2-container--default .location-select-dropdown .select2-results__option {
    margin: 2px 0;
    padding: 10px 11px;
    border-radius: calc(var(--location-select-radius) * .68);
    color: var(--location-select-option);
    line-height: 1.35;
    overflow-wrap: anywhere;
    white-space: normal;
}

.select2-container--default .location-select-dropdown .select2-results__option--selected {
    background: color-mix(in srgb, var(--location-select-accent) 16%, var(--location-select-bg-alt));
    color: var(--location-select-text);
}

.select2-container--default .location-select-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
    background: color-mix(in srgb, var(--location-select-accent) 30%, var(--location-select-bg-alt));
    color: var(--location-select-text);
}

.location-select-dropdown .select2-results__message {
    color: var(--location-select-muted);
}

body > .select2-container.storefront-location-select-layer {
    z-index: 10050;
    max-width: calc(100vw - 16px);
}

@media (max-width: 620px) {
    #cartDrawer .grid2 {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    #cartDrawer .checkout-step {
        padding-inline: 12px;
    }

    body > .select2-container.storefront-location-select-layer {
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-width: none;
    }

    .location-select-dropdown.select2-dropdown {
        width: 100% !important;
        max-width: none;
    }

    .location-select-dropdown .select2-results__options {
        max-height: min(240px, 38dvh) !important;
    }

    .select2-container--default .location-select-dropdown .select2-results__option {
        min-height: 42px;
        padding: 11px 12px;
    }
}
