/* =========================================================================
   BillboardMax — /finder/ (Billboard Finder)
   Full-viewport app layout: sticky brand header, slim search strip,
   map 80% wide on the left, scrollable single-column venues 20% on the right.
   Pairs with body.planner-page (flex column with footer pinned at bottom).
   ========================================================================= */

/* Pin the finder to exactly one viewport. The shared .planner-page body
 * is `min-height: 100dvh` which allows the body to GROW past the viewport
 * if children push it (then overflow:hidden silently clips, and the venues
 * column can't scroll because its parent isn't actually height-constrained).
 * Overriding both html + body to a fixed dvh fixes the entire flex chain:
 * the planner-header pins to top, planner-footer to bottom, .finder-main
 * fills the rest, .finder-split fills .finder-main minus the search strip,
 * map and venues each get .finder-split's height, and .finder-list-scroll
 * finally scrolls inside the venues column. */
html:has(body.finder-page) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}
body.finder-page {
    background: var(--bm-cloud);
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

/* The shared planner footer is link-heavy and steals vertical real estate
 * we can't spare on a mobile single-column layout. Hide it on the finder
 * page so the cart bar can own the bottom edge. */
@media (max-width: 992px) {
    body.finder-page .planner-footer { display: none !important; }
}

/* The planner header partial wraps its row in a Bootstrap .container which
 * caps width at ~1320px and centers it. On the finder we run edge-to-edge
 * (search strip + map + venues all span 100% of the viewport), so override
 * the header to match — keeps the brand aligned with everything below it. */
body.finder-page .planner-header > .container {
    max-width: none;
    width: 100%;
    padding-inline: clamp(0.75rem, 1.5vw, 1.25rem);
}

/* The main pane fills the space between the planner-header and the
 * planner-footer (which are flex-pinned by body.planner-page). */
.finder-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ---- Search strip ------------------------------------------------------- */

.finder-search-strip {
    background: radial-gradient(80% 60% at 50% 0%, rgba(255, 176, 32, 0.08) 0%, transparent 60%), linear-gradient(92deg, #ffffff 0%, #f2f8f9 35%, #ffffff 100%);
    border-bottom: 1px solid var(--bm-line);
    padding: 0.6rem clamp(0.75rem, 1.5vw, 1.25rem);
    flex-shrink: 0;
    /* Center the search form within the strip. Without this the grid
     * was left-aligned with a 1fr slack column shoving the button into
     * empty space on the right. */
    display: flex;
    justify-content: center;
    align-items: center;
}

.finder-search {
    display: grid;
    /* zip / radius / search-button / (root-only) advanced-toggle */
    grid-template-columns: minmax(0, 220px) minmax(0, 180px) auto auto;
    gap: 0.5rem;
    align-items: end;
    margin: 0;
    width: auto;
    max-width: 100%;
}

.finder-field { display: flex; flex-direction: column; gap: 0.2rem; }

.finder-field-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bm-muted);
    font-weight: 700;
    padding-left: 0.25rem;
}

.finder-search .form-control,
.finder-search .form-select {
    background: #fff;
    color: var(--bm-ink);
    border: 1px solid var(--bm-line);
    border-radius: 0.55rem;
    font-weight: 600;
    height: 38px;
    padding-block: 0.35rem;
}
.finder-search .form-control:focus,
.finder-search .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 176, 32, 0.25);
    border-color: var(--bm-amber);
}

.finder-search-btn {
    border-radius: 0.55rem;
    height: 38px;
    line-height: 1;
    white-space: nowrap;
    align-self: end;
    padding: 0 1.25rem;
    /* Force the icon + label onto a single perfectly centered baseline.
     * Without this the Bootstrap btn-amber inner text was sitting a
     * touch above the input baseline because the label had a larger
     * computed line-height than the 38px button box. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}
.finder-search-btn i { line-height: 1; margin-right: 0 !important; }

.finder-search-error {
    grid-column: 1 / -1;
    margin-top: 0.4rem;
    padding: 0.4rem 0.7rem;
    background: rgba(220, 53, 69, 0.08);
    color: #b02a37;
    border-radius: 0.45rem;
    font-size: 0.88rem;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* ---- Advanced Search (root-agency only) -------------------------------- *
 *
 * Checkbox sits next to the Search button. When checked, an additional
 * free-text input appears on its own row spanning the full grid width.
 * The zip + radius inputs stay enabled (the JS submit handler picks the
 * advanced query when the toggle is on, regardless of zip state) so an
 * operator can flip between modes without retyping. */
.finder-advanced-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 38px;
    align-self: end;
    padding: 0 0.65rem;
    border: 1px dashed var(--bm-line);
    border-radius: 0.55rem;
    background: rgba(11, 26, 43, 0.03);
    color: var(--bm-ink);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
}
.finder-advanced-toggle:hover { border-color: var(--bm-amber); }
.finder-advanced-toggle .form-check-input {
    margin: 0;
    cursor: pointer;
}
.finder-advanced-toggle .form-check-input:checked {
    background-color: var(--bm-amber);
    border-color: var(--bm-amber);
}

.finder-field--advanced .form-control {
    width: 100%;
    font-family: var(--bs-font-monospace, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 0.88rem;
    letter-spacing: 0.01em;
}

/* Advanced mode reflow — switch from the side-by-side default layout
 * to a stacked layout:
 *
 *   [ Find by uid · target_id · venue · industry_id ________________ ]   <- row 1, full width
 *   [ Search ]  [ ☑ Advanced Search ]                                    <- row 2, natural widths
 *
 * Done with grid-template-areas so the find-by input naturally spans
 * both columns on row 1 while the button + checkbox sit next to each
 * other on row 2. The column tracks size to the wider of (button/toggle
 * natural width, half of the find-by's min-width). */
.finder-search.is-advanced {
    grid-template-columns: auto auto;
    grid-template-areas:
        "field   field"
        "btn     toggle";
    column-gap: 0.5rem;
    row-gap: 0.5rem;
}
.finder-search.is-advanced .finder-field--zip,
.finder-search.is-advanced .finder-field--radius {
    display: none;
}
.finder-search.is-advanced .finder-field--advanced {
    grid-area: field;
    margin-top: 0;
    /* Roughly the combined ZIP+Range default width, so the row 1 input
     * feels as roomy as the pair of fields it replaces. */
    min-width: min(420px, calc(100vw - 2rem));
}
.finder-search.is-advanced .finder-search-btn {
    grid-area: btn;
    justify-self: start;
}
.finder-search.is-advanced .finder-advanced-toggle {
    grid-area: toggle;
    justify-self: start;
}

@media (max-width: 720px) {
    .finder-search-strip { padding: 0.5rem 0.75rem; }
    .finder-search {
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }
    .finder-search-btn { grid-column: 1 / -1; }
    .finder-advanced-toggle { grid-column: 1 / -1; justify-content: center; }

    /* Advanced mode on narrow screens — collapse the row-1/row-2
     * stacked layout into a single column so the find-by, search
     * button, and toggle each get their own full-width row. */
    .finder-search.is-advanced {
        grid-template-columns: 1fr;
        grid-template-areas:
            "field"
            "btn"
            "toggle";
    }
    .finder-search.is-advanced .finder-field--advanced {
        min-width: 0;
    }
    .finder-search.is-advanced .finder-search-btn,
    .finder-search.is-advanced .finder-advanced-toggle {
        justify-self: stretch;
    }
    .finder-search.is-advanced .finder-advanced-toggle {
        justify-content: center;
    }
}

/* ---- Split layout (80 / 20) -------------------------------------------- *
 * Flex (not grid) so the children stretch to fill the parent's flex height
 * automatically on the cross axis. Grid would need an explicit
 * grid-template-rows: 1fr to do the same — leaving it `auto` collapses the
 * row to content height, which in turn gives the map div 0 height and the
 * Google Maps SDK draws nothing.
 */
.finder-split {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    /* No gap — the map runs flush against the venues divider for an app feel. */
}

@media (max-width: 992px) {
    .finder-split {
        flex-direction: column;
    }
}

/* ---- Map pane ----------------------------------------------------------- */

.finder-map-pane {
    position: relative;
    min-width: 0;
    min-height: 0;
    flex: 0 0 80%;
    background: #e8eef5;
    overflow: hidden; /* clip any tile/marker overage to the pane bounds */
}
@media (max-width: 992px) {
    .finder-map-pane {
        flex: 0 0 50vh;
    }
}

.finder-map {
    position: relative;
    width: 100%;
    height: 100%;
    background: #e8eef5;
    overflow: hidden;
}

.finder-map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 3vw, 2rem);
    /* Soft scrim so the callout reads clearly over the map pane. */
    background: rgba(232, 238, 245, 0.92);
    /* Stays visible until the first search — then [hidden] removes it. */
    z-index: 2;
}
.finder-map-empty[hidden] { display: none !important; }

.finder-map-guide {
    max-width: 22rem;
    width: 100%;
    padding: 1.35rem 1.5rem 1.25rem;
    background: #fff;
    border: 1px solid var(--bm-line);
    border-radius: 1rem;
    box-shadow:
        0 1px 2px rgba(11, 26, 43, 0.06),
        0 12px 32px rgba(11, 26, 43, 0.12);
    text-align: center;
}
.finder-map-guide-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 0.85rem;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(255, 176, 32, 0.22) 0%, rgba(255, 176, 32, 0.08) 100%);
    color: var(--bm-amber);
    font-size: 1.55rem;
}
.finder-map-guide-title {
    margin: 0 0 0.85rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--bm-ink);
    letter-spacing: -0.02em;
    line-height: 1.25;
}
.finder-map-guide-steps {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: finder-step;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--bm-muted);
    line-height: 1.35;
}
.finder-map-guide-steps li {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
}
.finder-map-guide-steps li::before {
    content: counter(finder-step);
    counter-increment: finder-step;
    flex-shrink: 0;
    width: 1.45rem;
    height: 1.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bm-ink);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
}
.finder-map-guide-steps strong {
    color: var(--bm-ink);
    font-weight: 800;
}
.finder-map-guide-advanced {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--bm-muted);
    line-height: 1.45;
    text-align: left;
}
.finder-map-guide-advanced strong {
    color: var(--bm-ink);
    font-weight: 800;
}

/* ---- Venues pane (20% wide, full height, single-column scroll) --------- */

.finder-list-pane {
    flex: 0 0 20%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid var(--bm-line);
    overflow: hidden; /* only .finder-list-scroll inside is allowed to scroll */
}
@media (max-width: 992px) {
    .finder-list-pane {
        flex: 1 1 auto;
        border-left: 0;
        border-top: 1px solid var(--bm-line);
    }
}

.finder-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--bm-line);
    background: var(--bm-cloud);
    flex-shrink: 0;
}
.finder-status {
    font-weight: 600;
    color: var(--bm-muted);
    font-size: 0.82rem;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
}
.finder-status strong { color: var(--bm-ink); }
.finder-toolbar .btn { flex-shrink: 0; padding: 0.25rem 0.45rem; }

.finder-list-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem;
    scrollbar-width: thin;
}
/* Reserve room at the bottom of the venues scroll on mobile so the last
 * card isn't trapped behind the full-width cart bar. */
@media (max-width: 992px) {
    .finder-list-scroll {
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    }
}
.finder-list-scroll::-webkit-scrollbar { width: 8px; }
.finder-list-scroll::-webkit-scrollbar-thumb {
    background: rgba(11, 26, 43, 0.18);
    border-radius: 4px;
}
.finder-list-scroll::-webkit-scrollbar-thumb:hover { background: rgba(11, 26, 43, 0.32); }

.finder-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;  /* always single column */
    gap: 0.6rem;
}

/* ---- Cards (compact for the narrow column) -----------------------------
 *
 * Card visuals moved to /assets/css/venue-card.css so /plan/view/ can render
 * the same template via its detail drawer without depending on finder.css.
 * Both pages load venue-card.css ahead of any page-specific overrides. */


/* ---- Empty state -------------------------------------------------------- */

.finder-empty {
    text-align: center;
    padding: 2rem 0.75rem;
    color: var(--bm-muted);
    background: transparent;
    border: 1px dashed var(--bm-line);
    border-radius: 0.65rem;
}
.finder-empty i { font-size: 2rem; color: rgba(11, 26, 43, 0.3); }
.finder-empty h3 {
    font-size: 0.95rem;
    margin: 0.4rem 0 0.2rem;
    color: var(--bm-ink);
}
.finder-empty p { margin: 0; font-size: 0.85rem; }

/* ---- Sticky cart -------------------------------------------------------- */

.finder-cart {
    position: fixed;
    left: 40%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--bm-ink);
    color: #fff;
    border-radius: 999px;
    box-shadow: 0 12px 32px rgba(11, 26, 43, 0.35);
    padding: 0.45rem 0.5rem 0.45rem 1rem;
    width: fit-content;
    width: fit-content;
    white-space: nowrap;
    /* max-width: calc(100vw - 1.5rem); */
}
@media (max-width: 992px) {
    /* On mobile the cart becomes a full-width bottom bar that sits flush
     * under the venues scroll column — easier thumb reach, no overlap with
     * cards. The planner footer is hidden (rule below) so this bar owns
     * the bottom edge cleanly. */
    .finder-cart {
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        max-width: none;
        white-space: normal;
        border-radius: 0;
        padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -6px 18px rgba(11, 26, 43, 0.25);
    }
}
.finder-cart-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
@media (max-width: 992px) {
    .finder-cart-inner {
        justify-content: space-between;
        gap: 0.5rem;
    }
    .finder-cart-inner .btn { flex: 0 0 auto; }
}
.finder-cart-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
}
.finder-cart-summary i { color: var(--bm-amber); font-size: 1.15rem; }
.finder-cart-summary .js-finder-cart-count {
    background: var(--bm-amber);
    color: #1a1206;
    padding: 0.05rem 0.6rem;
    border-radius: 999px;
    font-weight: 800;
    min-width: 1.6rem;
    text-align: center;
}
.finder-cart .btn {
    border-radius: 999px;
    padding-block: 0.55rem;
}

/* ---- Map info window ---------------------------------------------------- *
 *
 * 1:1 port of plan-view's .plan-view-map-popup. The only intentional
 * divergences from public/assets/css/plan-view.css are:
 *   - selector prefix .finder-map-popup-* (instead of .plan-view-map-popup-*)
 *   - scope is .finder-map.is-google (instead of .plan-view-map.plan-view-inner-google)
 *   - the primary action button label is "Add to Plan" / "Remove" instead
 *     of "Select" / "Deselect" (label only — colors + states match).
 */

.finder-map .finder-map-popup {
    width: 260px;
    max-width: 260px;
    position: relative;
    margin: 0;
    padding: 0;
    font-family: Inter, system-ui, sans-serif;
}
.gm-style-iw-chr button.gm-ui-hover-effect{
    margin: -10px 0 0 0 !important;
}
.finder-map .finder-map-popup-id {
    position: absolute;
    top: 1px;
    left: 1px;
    z-index: 2;
    max-width: calc(100% - 3.25rem);
    padding: 0.2rem 0.42rem;
    border-radius: 0.4rem;
    background: rgb(11 26 43);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.finder-map .finder-map-popup-img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
    border-radius: 0;
    background: #f3f4f6;
}

.finder-map .finder-map-popup-title {
    display: -webkit-box;
    margin: 0;
    padding: 0.6rem 0.75rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    line-height: 1.25;
    font-weight: 700;
    font-size: 1rem;
    color: #0b1a2b;
}

.finder-map .finder-map-popup-sub {
    display: block;
    margin-top: 0.3rem;
    padding: 0 0.75rem 0.7rem;
    opacity: 0.82;
    font-size: 0.82rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #334155;
}

.finder-map .finder-map-popup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.42rem;
    padding: 0 0.75rem 0.75rem;
}

.finder-map .finder-map-popup-btn {
    border: 1px solid rgba(11, 26, 43, 0.12);
    border-radius: 0.5rem;
    background: #fff;
    color: #0b1a2b;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1;
    padding: 0.48rem 0.55rem;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
}

.finder-map .finder-map-popup-btn:hover,
.finder-map .finder-map-popup-btn:focus-visible {
    border-color: rgba(245, 158, 11, 0.72);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
    outline: 0;
}

.finder-map .finder-map-popup-btn--select {
    background: #ffbe33;
    border-color: #f59e0b;
    color: #111827;
}

.finder-map .finder-map-popup-btn--select.is-selected {
    background: #111827;
    border-color: #111827;
    color: #fff;
}

.finder-map .finder-map-popup-btn:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

/* Google InfoWindow chrome — strip padding so the image bleeds to the
 * rounded edge and the UID chip can float over the photo. Mirrors
 * plan-view.css's `.plan-view-map.plan-view-inner-google .gm-style …`.
 *
 * The chip is mounted as a direct child of `.gm-style-iw-c` (sibling to
 * `.gm-style-iw-d`) by mountInfoWindowIdChip() so its absolute positioning
 * anchors to the popup chrome and it is never clipped or scrolled with
 * the content. */
.finder-map.is-google .gm-style .gm-style-iw-c {
    padding: 0 !important;
    border-radius: 1rem !important;
    overflow: hidden !important;
    max-height: none !important;
}

/* No internal scrollbar — show the popup body in full. Google injects
 * an inline `max-height` on .gm-style-iw-d when it thinks the content
 * might overflow; the !important + overflow:visible neutralizes both
 * the scrollbar and the height clamp so the whole panel renders. */
.finder-map.is-google .gm-style .gm-style-iw-d {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    max-height: none !important;
}

.finder-map.is-google .gm-style .gm-style-iw-a > .gm-ui-hover-effect {
    top: 0.45rem !important;
    right: 0.45rem !important;
    width: 1.95rem !important;
    height: 1.95rem !important;
    border-radius: 999px !important;
    background: rgba(11, 26, 43, 0.52) !important;
    opacity: 1 !important;
}

.finder-map.is-google .gm-style .gm-style-iw-a > .gm-ui-hover-effect > span {
    margin: 4px !important;
    filter: brightness(0) invert(1);
}

.finder-map.is-google .gm-style-iw-chr {
    height: 25px;
}
