/* Map Listing toolbar pill (listing kind, property type, filter) and the square map tools.
   Moved verbatim out of Home/MapListing.css so the full map page and the homepage map preview
   (Client/Home/_HomeListingsShowcase) share one look. MapListing.css loads after this file and keeps
   its page-only placement and mobile overrides; the page defines --P / --PD / --T on :root, and a
   preview that does not sets them on .aq-map-controls below. */

.aq-map-controls {
    --P: #6A5D8B;
    --PD: #564a72;
    --T: #1c1829;
}

/* Toolbar always follows design L→R: segment | listing type | filter (even on RTL pages). */
.hdr-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    direction: ltr;
    unicode-bidi: isolate;
}

.hdr-bar__top-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.84);
    box-shadow: 0 10px 32px rgba(28, 24, 41, 0.18);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.hdr-bar__kind {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(220, 216, 233, 0.95);
}

html[dir="rtl"] .hdr-bar__kind {
    direction: rtl;
    justify-content: flex-start; /* Arabic: start chips from the right edge */
}

.hdr-bar__kind-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--T);
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

/*
 * Listing-type chips: DOM is [svg][label]. Parent `.hdr-bar__kind` is `direction: rtl`.
 * Use normal `flex-direction: row` so the first item (icon) sits at main-start = inline-end (right).
 * `row-reverse` was forcing the icon to the wrong side for most buttons.
 */
html[dir="rtl"] .hdr-bar__kind-btn {
    flex-direction: row;
}

/* Toolbar is `direction: ltr`; give property-type + filter their own RTL inline axis */
html[dir="rtl"] .hdr-bar__pt-wrap {
    direction: rtl;
}

html[dir="rtl"] .hdr-bar__filter {
    direction: rtl;
    flex-direction: row;
}

.hdr-bar__kind-btn .hdr-ic,
.hdr-bar__kind-btn svg.hdr-ic {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    opacity: .85;
}

.hdr-bar__kind-btn.on {
    background: var(--P);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}

.hdr-bar__kind-btn.on .hdr-ic {
    color: #fff;
    opacity: 1;
}

/* Property type — pill trigger + custom dropdown (native <select> list cannot be styled) */
.hdr-bar__pt-wrap {
    --hdr-pt-fill: rgba(106, 93, 139, 0.08);
    position: relative;
    display: inline-flex;
    align-items: stretch;
    min-height: 38px;
    min-width: 175px;
    max-width: min(340px, calc(100vw - 200px));
    border-radius: 999px;
    border: 1px solid rgba(106, 93, 139, 0.16);
    background: var(--hdr-pt-fill);
    flex: 0 0 auto;
    box-sizing: border-box;
    color-scheme: light;
}

.hdr-bar__pt-wrap:hover {
    --hdr-pt-fill: rgba(106, 93, 139, 0.1);
    border-color: rgba(106, 93, 139, 0.28);
}

.hdr-bar__pt-trigger {
    flex: 1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 4px 10px 4px 12px;
    margin: 0;
    border: none;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--T);
    text-align: start;
    line-height: 1.35;
    -webkit-tap-highlight-color: transparent;
}

.hdr-bar__pt-trigger:focus {
    outline: none;
}

.hdr-bar__pt-trigger:focus-visible {
    box-shadow: 0 0 0 2px rgba(106, 93, 139, 0.35);
}

.hdr-bar__pt-trigger.is-open .hdr-bar__pt-chevron {
    transform: rotate(180deg);
}

.hdr-bar__pt-trigger-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: plaintext;
}

.hdr-bar__pt-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    margin-inline-start: 2px;
}

.hdr-bar__pt-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--P);
    opacity: .92;
    pointer-events: none;
}

.hdr-bar__pt-ic .hdr-ic {
    display: block;
}

/* Dropdown panel */
.hdr-bar__pt-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    z-index: 50;
    min-width: max(100%, 268px);
    max-width: min(340px, calc(100vw - 32px));
    max-height: min(420px, 62vh);
    padding: 8px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(106, 93, 139, 0.14);
    box-shadow: 0 16px 48px rgba(28, 24, 41, 0.18), 0 4px 16px rgba(28, 24, 41, 0.08);
    box-sizing: border-box;
}

html[dir="rtl"] .hdr-bar__pt-dropdown {
    left: auto;
    right: 0;
}

html[dir="rtl"] .hdr-bar__pt-trigger {
    text-align: right;
    /* DOM: [icon][label][chevron] — `direction: rtl` on `.hdr-bar__pt-wrap` places icon on the right */
    flex-direction: row;
}

.hdr-bar__pt-list {
    max-height: min(396px, calc(62vh - 24px));
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(106, 93, 139, 0.35) transparent;
}

.hdr-bar__pt-list::-webkit-scrollbar {
    width: 6px;
}

.hdr-bar__pt-list::-webkit-scrollbar-thumb {
    background: rgba(106, 93, 139, 0.3);
    border-radius: 6px;
}

/* Mobile: JS sets position:fixed + width (see positionMapHdrPtDropdownForMobile) — flex so the list scrolls inside max-height */
@media (max-width: 768px) {
    .hdr-bar__pt-dropdown[data-mob-placed="1"] {
        display: flex;
        flex-direction: column;
        min-width: 0 !important;
        z-index: 10060;
    }

    .hdr-bar__pt-dropdown[data-mob-placed="1"] .hdr-bar__pt-list {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
    }
}

.hdr-bar__pt-section {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 12px 8px;
    margin: 4px 0 2px;
    font-family: 'Rubik', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--PD);
    background: linear-gradient(180deg, #ede9f5 0%, #e8e3f2 100%);
    border-radius: 10px;
    border: 1px solid rgba(106, 93, 139, 0.12);
    text-align: center;
}

.hdr-bar__pt-item {
    display: block;
    width: 100%;
    margin: 2px 0;
    padding: 10px 14px;
    border: none;
    border-radius: 12px;
    background: transparent;
    font-family: 'Rubik', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--T);
    text-align: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    unicode-bidi: plaintext;
}

html[dir="rtl"] .hdr-bar__pt-item {
    text-align: right;
}

.hdr-bar__pt-item:hover {
    background: rgba(106, 93, 139, 0.08);
    color: var(--PD);
}

.hdr-bar__pt-item.is-selected {
    background: var(--P);
    color: #fff;
    font-weight: 600;
}

.hdr-bar__pt-item.is-selected:hover {
    background: var(--PD);
    color: #fff;
}

.hdr-bar__filter {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    min-height: 39px;
    border-radius: 999px;
    border: 1px solid rgba(220, 216, 233, 0.95);
    background: #fff;
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--T);
    cursor: pointer;
}

html[dir="rtl"] .hdr-bar__filter {
    unicode-bidi: plaintext;
}

.hdr-bar__filter .hdr-ic,
.hdr-bar__filter svg.hdr-ic {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.hdr-bar__filter:hover {
    border-color: rgba(179, 172, 199, 0.95);
}

.hdr-bar__filter.on {
    border-color: rgba(106, 93, 139, 0.6);
    color: var(--PD);
    background: rgba(237, 233, 245, 0.8);
}

.map-tool-square {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border-radius: 12px;
    border: 1px solid rgba(106, 93, 139, 0.14);
    background: #fff;
    color: var(--PD, #564a72);
    box-shadow: 0 4px 14px rgba(28, 24, 41, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: transform .15s ease, border-color .15s, box-shadow .15s, background .15s, color .15s;
}

.map-tool-square svg,
.map-tool-square .map-layers-ic {
    width: 20px;
    height: 20px;
    display: block;
    flex-shrink: 0;
}

.map-tool-square:hover {
    transform: translateY(-1px);
    border-color: rgba(106, 93, 139, 0.28);
    box-shadow: 0 6px 18px rgba(28, 24, 41, 0.16);
    color: var(--P, #6A5D8B);
}

.map-tool-square:active {
    transform: scale(0.97);
}

.map-tool-square:focus-visible {
    outline: 2px solid var(--P, #6A5D8B);
    outline-offset: 2px;
}

.map-tool-square[aria-pressed="true"],
.map-tool-square.is-active,
.map-tool-square.on {
    background: var(--P, #6A5D8B);
    border-color: var(--PD, #564a72);
    color: #fff;
    box-shadow: 0 4px 14px rgba(106, 93, 139, 0.35);
}

/* Desktop tooltip from data-tip */
@media (hover: hover) and (min-width: 769px) {
    .map-tool-square[data-tip]::after {
        content: attr(data-tip);
        position: absolute;
        top: 50%;
        left: calc(100% + 10px);
        transform: translateY(-50%);
        white-space: nowrap;
        padding: 5px 9px;
        border-radius: 8px;
        background: rgba(28, 24, 41, 0.92);
        color: #fff;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.2;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        transition: opacity .15s ease;
        z-index: 5;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
    }

    html[dir="rtl"] .map-tool-square[data-tip]::after {
        left: auto;
        right: calc(100% + 10px);
    }

    .map-tool-square[data-tip]:hover::after,
    .map-tool-square[data-tip]:focus-visible::after {
        opacity: 1;
        visibility: visible;
    }
}

.map-tool-square--layers,
.map-tool-square--locate,
.map-tool-square--3d,
.map-tool-square--reset,
.map-tool-square--district-overlay,
.map-tool-square--parcel-layer {
    border: 1px solid rgba(106, 93, 139, 0.14);
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--PD, #564a72);
    box-shadow: 0 4px 14px rgba(28, 24, 41, 0.12);
}

.map-tool-square--layers:hover,
.map-tool-square--locate:hover {
    border-color: rgba(106, 93, 139, 0.28);
    background: #fff;
    color: var(--P, #6A5D8B);
    box-shadow: 0 6px 18px rgba(28, 24, 41, 0.16);
}

.map-tool-square--layers:active,
.map-tool-square--locate:active {
    transform: scale(0.97);
}

.map-tool-square--3d,
.map-tool-square--reset {
    border: 1px solid rgba(106, 93, 139, 0.14);
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--PD, #564a72);
    box-shadow: 0 4px 14px rgba(28, 24, 41, 0.12);
}

.map-tool-square--3d.on {
    background: var(--P, #6A5D8B);
    border-color: var(--PD, #564a72);
    color: #fff;
}

.map-tool-square--district-overlay,
.map-tool-square--parcel-layer {
    border: 1px solid rgba(106, 93, 139, 0.14);
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--PD, #564a72);
    box-shadow: 0 4px 14px rgba(28, 24, 41, 0.12);
}

.map-tool-square--district-overlay.is-active,
.map-tool-square--parcel-layer.is-active {
    background: var(--P, #6A5D8B);
    border-color: var(--PD, #564a72);
    color: #fff;
}

.map-tool-square--parcel-layer.is-unavailable {
    opacity: 0.6;
}

/* Active colours of the parcel and district-colour squares (the ids the layer scripts bind to). */
#mapParcelLayerBtn.is-active {
    background: #0f766e;
    color: #fff;
    border-color: #0f766e;
}

#mapParcelLayerBtn.is-unavailable {
    opacity: 0.72;
}

#mapDistrictOverlayBtn.is-active {
    background: #c96b4a;
    color: #fff;
    border-color: #c96b4a;
}
