/* ──────────────────────────────────────────────────────────────────────────────
   Branch picker  (resources/views/partials/location-picker.blade.php)

   Shared by the platform business page and the merchant microsite, so it carries
   its own tokens rather than inheriting: a microsite defines --muted/--accent as
   oklch *surfaces* and half the designs are dark-scheme, so inherited values put
   near-white text on near-white cards.
   ────────────────────────────────────────────────────────────────────────────── */

.lp {
    --lp-ink: #101214;
    --lp-muted: #5f6770;
    --lp-line: #e6e8eb;
    --lp-surface: #ffffff;
    --lp-soft: #f7f8f9;
    --lp-accent: #0f6c37;
    --lp-accent-soft: #eaf5ee;

    position: relative;
    /* Above the sticky headers this sits beneath — the microsite's is z-40 and the
       platform nav is z-60. The open panel used to render behind both. */
    z-index: 70;
    display: block;
    max-width: 560px;
    font-family: "Public Sans", ui-sans-serif, system-ui, sans-serif;
    color: var(--lp-ink);
}

.lp *, .lp *::before, .lp *::after { box-sizing: border-box; }

/* A closed picker must not sit in a stacking context above the page chrome. */
.lp:not([open]) { z-index: 1; }

/* ── Trigger ──────────────────────────────────────────────────────────────── */

.lp-trigger {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--lp-line);
    border-radius: 14px;
    background: var(--lp-surface);
    cursor: pointer;
    list-style: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

/* Kill the native disclosure triangle in every engine. */
.lp-trigger::-webkit-details-marker { display: none; }
.lp-trigger::marker { content: ''; }

.lp-trigger:hover {
    border-color: #cfd4d9;
    box-shadow: 0 6px 18px rgba(16, 18, 20, 0.06);
}

.lp-trigger:focus-visible {
    outline: 2px solid var(--lp-accent);
    outline-offset: 2px;
}

.lp[open] .lp-trigger {
    border-color: #cfd4d9;
    background: var(--lp-soft);
}

.lp-pin {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--lp-accent-soft);
    color: var(--lp-accent);
}

.lp-trigger-text { min-width: 0; }

.lp-label {
    display: block;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lp-muted);
}

.lp-current {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    margin-top: 1px;
}

.lp-name {
    flex: none;
    max-width: 55%;
    overflow: hidden;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* The address is the first thing to give up room — the branch name identifies it. */
.lp-addr {
    min-width: 0;
    overflow: hidden;
    font-size: 0.8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--lp-muted);
}

.lp-trigger-end {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lp-dist {
    flex: none;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--lp-soft);
    border: 1px solid var(--lp-line);
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--lp-muted);
    white-space: nowrap;
}

.lp-change {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--lp-accent);
    white-space: nowrap;
}

.lp-caret { transition: transform 0.22s ease; }
.lp[open] .lp-caret { transform: rotate(180deg); }

/* ── Panel ────────────────────────────────────────────────────────────────── */

.lp-scrim { display: none; }

.lp-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 2;
    overflow: hidden;
    border: 1px solid var(--lp-line);
    border-radius: 16px;
    background: var(--lp-surface);
    box-shadow: 0 20px 44px rgba(16, 18, 20, 0.16);
    animation: lp-in 0.18s ease;
}

@keyframes lp-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lp-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--lp-line);
    background: var(--lp-soft);
}

.lp-panel-title {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 700;
}

.lp-panel-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--lp-muted);
}

.lp-panel-close {
    display: none;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--lp-line);
    border-radius: 999px;
    background: var(--lp-surface);
    color: var(--lp-ink);
    cursor: pointer;
}

.lp-options {
    max-height: 340px;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
}

.lp-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 11px 12px;
    border-radius: 11px;
    text-decoration: none;
    color: inherit;
    transition: background 0.14s ease;
}

.lp-option:hover,
.lp-option:focus-visible { background: var(--lp-soft); outline: none; }

.lp-option:focus-visible { box-shadow: inset 0 0 0 2px var(--lp-accent); }

.lp-option.is-current { background: var(--lp-accent-soft); }

.lp-option-mark {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    margin-top: 1px;
    border-radius: 999px;
    background: var(--lp-surface);
    border: 1px solid var(--lp-line);
    color: var(--lp-muted);
}

.lp-option.is-current .lp-option-mark {
    background: var(--lp-accent);
    border-color: var(--lp-accent);
    color: #fff;
}

.lp-option-body { min-width: 0; }

.lp-option-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 700;
}

.lp-option-state {
    flex: none;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--lp-accent);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.lp-option-addr {
    display: block;
    margin-top: 2px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--lp-muted);
}

.lp-option-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 5px;
    font-size: 0.74rem;
    color: var(--lp-muted);
}

.lp-option-dist {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--lp-ink);
}

.lp-option-dist + .lp-option-phone::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 3px;
    margin-right: 8px;
    border-radius: 999px;
    background: currentColor;
    vertical-align: middle;
}

/* ── Phones: the panel becomes a sheet, so a long branch list is reachable ─── */

@media (max-width: 640px) {
    .lp { max-width: none; }
    .lp[open] { z-index: 1000; }

    .lp-trigger { border-radius: 12px; padding: 9px 12px; gap: 10px; }
    .lp-name { max-width: 100%; }
    .lp-current { flex-direction: column; align-items: flex-start; gap: 0; }
    .lp-change { font-size: 0; gap: 0; }           /* caret alone — the row is the control */
    .lp-caret { width: 18px; height: 18px; }

    /* The sheet is modal, so it clears the cookie consent banner (z-index 940) the
       same way the quick cart does. Both the scrim and the panel escape .lp's own
       stacking context by being fixed, so they need the real values here. */
    .lp[open] .lp-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1000;
        background: rgba(12, 14, 16, 0.44);
    }

    .lp-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        max-height: 80vh;
        border: 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -18px 44px rgba(16, 18, 20, 0.24);
        animation: lp-up 0.24s cubic-bezier(0.32, 0.72, 0, 1);
    }

    @keyframes lp-up {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    .lp-panel-head { padding: 14px 16px; }
    .lp-panel-close { display: grid; }
    .lp-options { max-height: calc(80vh - 58px); padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .lp-panel { animation: none; }
    .lp-caret, .lp-trigger, .lp-option { transition: none; }
}

/* ── Host wrappers ────────────────────────────────────────────────────────── */

/* Platform business page: the picker introduces the catalogue below it. */
.bp-location-picker { margin: 0 0 20px; }

/* Microsite: a full-width band under the sticky header. `position: relative` with no
   z-index keeps the band out of the header's way while the picker itself raises above
   it when open. */
.ms-location-bar {
    position: relative;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    /* Deliberately NOT backdrop-filter: that creates a stacking context, which traps
       the picker's z-index inside this bar and renders the open panel behind the
       sticky header above it — whatever z-index the picker itself is given. */
    background: #ffffff;
}

.ms-location-bar__inner {
    width: min(1280px, 100%);
    margin: 0 auto;
    padding: 10px 24px;
}

@media (max-width: 640px) {
    .ms-location-bar__inner { padding: 8px 16px; }
}
