/*
 * The front property search widget.
 *
 * A second sheet layered over `search.css` rather than edits inside it:
 * `search.css` is also the developer-search widget's sheet
 * (`front/developers/search.blade.php` reuses `.searchOptions`,
 * `.collapseSearch`, `.estateTypeLabel`...), so changing those selectors would
 * restyle a screen this work never looked at. Everything here is prefixed
 * `sw-` / `sw__`, the way `property-search.css` owns `psr-`, and the two
 * property screens now share one palette.
 *
 * Loaded after `search.css` on the home page and the results page.
 */

:root {
    --sw-accent: #05af78;
    --sw-accent-dark: #048d61;
    --sw-accent-soft: rgba(5, 175, 120, .12);
    --sw-cta: #af2029;
    --sw-cta-dark: #8e1a21;
    --sw-ink: #1d2a3b;
    --sw-muted: #6b7490;
    --sw-line: #e7ebf1;
    --sw-surface: #fff;
    --sw-radius: 14px;
    --sw-shadow: 0 2px 14px rgba(29, 42, 59, .07);
    --sw-shadow-pop: 0 18px 46px rgba(29, 42, 59, .18);
    --sw-field-h: 58px;
}

/* ---------------------------------------------------------------- the panel */

/*
 * Above `.searchOverlay` (1000), which dims the rest of the page while a
 * dropdown is open: at the old 998 the overlay greyed out the widget the
 * visitor was in the middle of using.
 */
.sw {
    position: relative;
    z-index: 1001;
}

.sw__panel {
    padding: 1rem .75rem;
}

@media (min-width: 992px) {
    .sw__panel {
        padding: 1.1rem 1.25rem 1.25rem;
    }
}

/* ---------------------------------------------------------------- the deals */

.sw__deals {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    margin-bottom: .9rem;
}

.sw__deals .customSelectButton + .customSelectButton-label {
    margin: 0;
    padding: 9px 26px;
    font-size: 13px;
    letter-spacing: .01em;
}

.sw__deals .customSelectButton:checked + .customSelectButton-label {
    background-color: var(--sw-accent);
    border-color: rgba(255, 255, 255, .35);
    box-shadow: 0 6px 18px rgba(5, 175, 120, .35);
}

.sw__deals .customSelectButton:focus-visible + .customSelectButton-label {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ the bar */

.sw__bar {
    display: grid;
    grid-template-columns: 1fr;
    background: var(--sw-surface);
    border-radius: var(--sw-radius);
    box-shadow: var(--sw-shadow);
}

@media (min-width: 768px) {
    .sw__bar {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 992px) {
    .sw__bar {
        /* estate | location | price | area | more | word | submit */
        grid-template-columns: 1.05fr 1.05fr 1fr 1fr auto minmax(120px, .95fr) auto;
    }

    /* The developer bar: subdistrict | status | price | word | submit. */
    .sw__bar--4 {
        grid-template-columns: 1.15fr 1fr 1fr 1.1fr auto;
    }
}

/*
 * Separators are drawn as insets on the cell rather than as borders on the
 * bar, so a cell can still paint its own hover background edge to edge and
 * the rounded corners stay clean.
 */
.sw__cell {
    position: relative;
    min-width: 0;
}

.sw__cell + .sw__cell::before {
    content: '';
    position: absolute;
    background: var(--sw-line);
    left: 16px;
    right: 16px;
    top: 0;
    height: 1px;
}

@media (min-width: 768px) {
    .sw__cell:nth-child(odd) + .sw__cell::before {
        left: 0;
        right: auto;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 60%;
    }
}

@media (min-width: 992px) {
    .sw__cell + .sw__cell::before {
        left: 0;
        right: auto;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 58%;
    }

    .sw__cell + .sw__cell:last-child::before {
        opacity: 0;
    }
}

/* ---------------------------------------------------------------- triggers */

.sw__trigger {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    height: var(--sw-field-h);
    padding: 0 1rem;
    border: 0;
    background: transparent;
    text-align: start;
    cursor: pointer;
    border-radius: var(--sw-radius);
    transition: background-color .18s ease;
}

.sw__trigger:hover,
.sw__trigger:focus-visible {
    background: rgba(5, 175, 120, .06);
}

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

.sw__text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1 1 auto;
}

.sw__label {
    font-size: 10.5px;
    line-height: 1.2;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sw-muted);
    white-space: nowrap;
}

.sw__value {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--sw-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sw__value.is-empty {
    font-weight: 500;
    color: #9aa2b5;
}

.sw__icon {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--sw-muted);
    transition: transform .2s ease, color .18s ease;
}

.sw__trigger:hover .sw__icon {
    color: var(--sw-accent);
}

.sw__trigger[aria-expanded="true"] .sw__caret {
    transform: rotate(180deg);
    color: var(--sw-accent);
}

/* ----------------------------------------------------------------- the word */

.sw__word {
    display: flex;
    align-items: center;
    height: var(--sw-field-h);
    padding: 0 .35rem 0 1rem;
}

.sw__word .searchWord {
    height: auto;
    padding: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--sw-ink);
    background: transparent;
}

.sw__word .searchWord::placeholder {
    font-weight: 500;
    font-size: 13px;
    color: #9aa2b5;
}

.sw__word .searchWord:focus {
    outline: none;
}

/* ----------------------------------------------------------- advanced + CTA */

.sw__more {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    width: 100%;
    height: var(--sw-field-h);
    padding: 0 1rem;
    border: 0;
    background: transparent;
    color: var(--sw-ink);
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease;
}

.sw__more:hover,
.sw__more:focus-visible {
    color: var(--sw-accent);
    background: rgba(5, 175, 120, .06);
}

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

.sw__more-text {
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

@media (min-width: 992px) {
    .sw__more-text {
        display: none;
    }
}

/* How many advanced filters are currently applied. */
.sw__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--sw-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.sw__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    height: var(--sw-field-h);
    padding: 0 1.5rem;
    border: 0;
    background: var(--sw-cta);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .02em;
    border-radius: 0 0 var(--sw-radius) var(--sw-radius);
    cursor: pointer;
    transition: background-color .18s ease;
}

.sw__submit:hover,
.sw__submit:focus-visible {
    background: var(--sw-cta-dark);
}

.sw__submit:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -4px;
}

.sw__submit-text {
    display: inline;
}

@media (min-width: 768px) {
    .sw__submit {
        border-radius: 0 0 var(--sw-radius) 0;
    }
}

@media (min-width: 992px) {
    .sw__submit {
        border-radius: 0 var(--sw-radius) var(--sw-radius) 0;
        padding: 0 1.75rem;
    }

    .sw__submit-text {
        display: none;
    }

    .sw__submit i {
        font-size: 16px;
    }
}

@media (min-width: 1200px) {
    .sw__submit {
        padding: 0 2.25rem;
    }

    .sw__submit-text {
        display: inline;
    }
}

/* ------------------------------------------------------------- the dropdown */

/*
 * Deliberately not Bootstrap's `.collapse`. The layout loads Tailwind through
 * `@vite` whenever `APP_DEBUG` is on, and Tailwind's own `collapse` utility is
 * `visibility: collapse` — so on any developer's machine a `.collapse.show`
 * panel laid itself out at full size and painted nothing at all. Two
 * frameworks claim that class name; the widget uses neither.
 */
.sw__pop {
    display: none;
    position: absolute;
    z-index: 1002;
    top: calc(100% + 10px);
    left: 0;
    width: min(420px, calc(100vw - 2rem));
    padding: 1.1rem 1.15rem 1.25rem;
    background: var(--sw-surface);
    border: 1px solid var(--sw-line);
    border-radius: var(--sw-radius);
    box-shadow: var(--sw-shadow-pop);
}

.sw__pop.is-open {
    display: block;
}

/*
 * The old sheet pinned the arrow at a fixed `left: 119px`, which only ever
 * lined up under the first column; it is anchored to its own cell here.
 */
.sw__pop::before,
.sw__pop::after {
    content: '';
    position: absolute;
    left: 28px;
    width: 0;
    height: 0;
    border-style: solid;
}

.sw__pop::before {
    top: -9px;
    border-width: 0 9px 9px 9px;
    border-color: transparent transparent var(--sw-line) transparent;
}

.sw__pop::after {
    top: -8px;
    border-width: 0 8px 8px 8px;
    border-color: transparent transparent var(--sw-surface) transparent;
}

/* A dropdown under a right-hand cell is right-aligned so it stays on screen. */
.sw__pop--end {
    left: auto;
    right: 0;
}

.sw__pop--end::before,
.sw__pop--end::after {
    left: auto;
    right: 28px;
}

.sw__pop--wide {
    width: min(620px, calc(100vw - 2rem));
}

.sw__pop-title {
    display: block;
    margin-bottom: .8rem;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--sw-muted);
}

.sw__pop-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.sw__pop-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
    width: 100%;
    margin-top: 1rem;
}

.sw__pop .form-control {
    height: 46px;
    border-color: var(--sw-line);
    border-radius: 10px;
    font-size: 13.5px;
    color: var(--sw-ink);
}

.sw__pop .form-control:focus {
    border-color: var(--sw-accent);
    box-shadow: 0 0 0 3px var(--sw-accent-soft);
}

/* Estate-type radios inside the dropdown. */
.sw__pop .estateSelectList {
    justify-content: flex-start;
    gap: .15rem;
    margin: -5px;
}

/* ------------------------------------------------------- a list in a panel */

.sw__filter {
    margin-bottom: .7rem;
}

.sw__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    max-height: 260px;
    overflow-y: auto;
    /* Room for the scrollbar, so a long name never sits under it. */
    padding-right: 4px;
    margin-right: -4px;
}

.sw__list--plain {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
}

.sw__option {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .42rem .55rem;
    border-radius: 9px;
    font-size: 13px;
    color: var(--sw-ink);
    cursor: pointer;
    transition: background-color .15s ease;
}

.sw__option:hover {
    background: var(--sw-accent-soft);
}

.sw__option.is-hidden {
    display: none;
}

.sw__option input {
    position: absolute;
    left: -9999px;
}

.sw__option span {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sw__option span::before {
    content: '';
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-right: .5rem;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1.5px #c3cad8;
    transition: box-shadow .15s ease;
}

.sw__option input:checked + span {
    font-weight: 600;
    color: var(--sw-accent-dark);
}

.sw__option input:checked + span::before {
    box-shadow: inset 0 0 0 5px var(--sw-accent);
}

.sw__option input:focus-visible + span::before {
    outline: 2px solid var(--sw-accent);
    outline-offset: 2px;
}

/* The desktop dropdowns are inert on phones - the offcanvas sheets take over. */
@media (max-width: 991.98px) {
    .sw__pop:not(.sw__pop--always) {
        display: none !important;
    }

    /*
     * A cell with no offcanvas twin keeps its panel on a phone, where it reads
     * better inline than floating over the stacked bar.
     */
    .sw__pop--always.is-open {
        position: static;
        width: auto;
        margin: 0 .5rem .75rem;
        box-shadow: none;
    }

    .sw__pop--always::before,
    .sw__pop--always::after {
        display: none;
    }

    .sw__list {
        grid-template-columns: 1fr;
        max-height: 50vh;
    }
}

/* ---------------------------------------------------------- the pill toggle */

.sw__pop .switch-wrapper,
.sw-sheet .switch-wrapper {
    border-color: var(--sw-line);
    background: #f2f4f8;
}

.sw__pop .switch-wrapper .highlighter,
.sw-sheet .switch-wrapper .highlighter {
    background: var(--sw-accent);
}

.sw__pop .switch-wrapper label {
    min-width: 68px;
}

/* -------------------------------------------------------------- the overlay */

.searchOverlay.active {
    position: fixed !important;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(9, 16, 28, .32);
}

/* ------------------------------------------------------ results-page extras */

.sw__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-top: .85rem;
}

/*
 * Solid rather than another pane of glass: the panel is translucent, and how
 * far the hero or the page-title band reaches behind it differs per page — on
 * the developer index it stops short, which left a white chip on white.
 */
.sw__reset {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: 7px 16px;
    border: 1px solid var(--sw-line);
    border-radius: 20px;
    background: var(--sw-surface);
    color: var(--sw-ink);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--sw-shadow);
    transition: background-color .18s ease, color .18s ease;
}

.sw__reset:hover,
.sw__reset:focus-visible {
    background: var(--sw-accent);
    border-color: var(--sw-accent);
    color: #fff;
}

/*
 * On the results page the widget sits on the page background rather than over
 * the hero image, so the glass treatment has nothing to sit on and the white
 * labels are unreadable. It gets a solid card there instead.
 */
.sw--results {
    margin-top: -70px;
}

.sw--results .main-search-background {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.42);
}

/* ------------------------------------------------------------ mobile sheets */

.sw-sheet .offcanvas-header {
    padding-bottom: .35rem;
}

.sw-sheet .offcanvas-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--sw-ink);
}

.sw-sheet .offcanvas-body {
    padding-top: .25rem;
}

.sw-sheet__done {
    width: 100%;
    height: 48px;
    margin-top: 1.1rem;
    border: 0;
    border-radius: 10px;
    background: var(--sw-accent);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
}

.sw-sheet__done:hover,
.sw-sheet__done:focus-visible {
    background: var(--sw-accent-dark);
}
