/**
 * Filter Bar + More Filters Panel + Pagination
 * Community and high-rise pages
 * @since 2.3.0
 */

/* ── Filter bar row ─────────────────────────────────────────────────────────── */
.trg-filter-bar {
    background: #fff;
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

.trg-filter-bar__inner {
    max-width: var(--container-max, 1280px);
    margin-inline: auto;
    padding: 4px var(--container-pad, clamp(1rem, 4vw, 2rem));
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

/* ── Filter bar left/right groups ───────────────────────────────────────────── */
.trg-filter-bar__left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.trg-filter-bar__right {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    flex-shrink: 0;
}

.trg-filter-sep {
    width: 0.5px;
    height: 12px;
    background: rgba(0,0,0,0.15);
    flex-shrink: 0;
    margin: 0 2px;
}

/* ── Capsule style (filter pills + sort pills) ─────────────────────────────── */
.trg-cap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #282460;
    border-radius: 20px;
    padding: 4px 12px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    color: #282460;
    background: #fff;
    white-space: nowrap;
    user-select: none;
    position: relative;
}
.trg-cap:hover {
    background: #282460;
    color: #fff;
}
.trg-cap:hover .cap-label,
.trg-cap:hover .cap-value,
.trg-cap:hover .cap-arrow {
    color: #fff;
    opacity: 1;
}
.trg-cap.active {
    background: #282460;
    color: #fff;
    border-color: #282460;
}
.trg-cap .cap-label { color: #282460; font-weight: 500; opacity: 0.7; }
.trg-cap.active .cap-label { color: rgba(255,255,255,0.7); opacity: 1; }
.trg-cap .cap-value { font-weight: 700; color: #282460; }
.trg-cap.active .cap-value { color: #fff; }
.trg-cap .cap-arrow { font-size: 7px; color: #282460; opacity: 0.6; }
.trg-cap.active .cap-arrow { color: rgba(255,255,255,0.7); opacity: 1; }

/* ── More Filters button ────────────────────────────────────────────────────── */
.trg-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: #282460;
    white-space: nowrap;
    line-height: 1.5;
}
.trg-more-btn:hover {
    opacity: 0.9;
}

/* ── Popover dropdown ───────────────────────────────────────────────────────── */
.trg-popover {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 12px;
    min-width: 220px;
}
.trg-popover.open { display: block; }

.trg-popover__title {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
}

/* Range inputs inside popovers */
.trg-popover__range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.trg-popover__range input {
    flex: 1;
    border: 1px solid #282460;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: var(--font-heading);
    outline: none;
    width: 90px;
    color: #282460;
}
.trg-popover__range input:focus {
    border-color: #282460;
}
.trg-popover__range-sep {
    color: #ccc;
    font-size: 11px;
}

/* Quick-select hint pills inside price popover */
.trg-popover__hints {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.trg-popover__hint {
    font-size: 10px;
    padding: 2px 8px;
    border: 1px solid #282460;
    border-radius: 12px;
    background: #fff;
    color: #282460;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 500;
}
.trg-popover__hint:hover {
    background: #282460;
    color: #fff;
}

/* Price select dropdowns */
.trg-price-selects {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.trg-price-selects__sep {
    font-size: 13px;
    color: #666;
    flex-shrink: 0;
}
.trg-price-select__input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font-body, sans-serif);
    color: #333;
    background: white;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    min-width: 100px;
    max-width: 140px;
}
.trg-price-select__input:focus {
    outline: none;
    border-color: #1B2A4A;
}
.trg-price-select__input::-ms-expand {
    display: none;
}

/* Pill selectors inside popovers */
.trg-popover__pills {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.trg-popover__pill {
    font-size: 11px;
    padding: 4px 10px;
    border: 1px solid #282460;
    border-radius: 14px;
    background: #fff;
    color: #282460;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 500;
    transition: background 0.1s, color 0.1s;
}
.trg-popover__pill:hover {
    background: #282460;
    color: #fff;
}
.trg-popover__pill.active {
    background: #282460;
    color: #fff;
    border-color: #282460;
}

/* Apply button inside popovers */
.trg-popover__apply {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 6px;
    border: none;
    border-radius: 6px;
    background: #282460;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.trg-popover__apply:hover {
    opacity: 0.9;
}

/* ── More Filters slide-out panel ───────────────────────────────────────────── */
.trg-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9998;
}
.trg-panel-overlay.open { display: block; }

.trg-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 90vw;
    background: #fff;
    z-index: 9999;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    flex-direction: column;
    overflow: hidden;
}
.trg-panel.open {
    display: flex;
}

.trg-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.trg-panel__title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}
.trg-panel__close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}
.trg-panel__close:hover { color: #282460; }

.trg-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.trg-panel__section {
    margin-bottom: 16px;
}
.trg-panel__section-title {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 6px;
}
.trg-panel__section-pills {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.trg-panel__pill {
    font-size: 11px;
    padding: 4px 10px;
    border: 1px solid #282460;
    border-radius: 14px;
    background: #fff;
    color: #282460;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 500;
}
.trg-panel__pill:hover { background: #282460; color: #fff; }
.trg-panel__pill.active {
    background: #282460;
    color: #fff;
    border-color: #282460;
}

.trg-panel__range {
    display: flex;
    align-items: center;
    gap: 8px;
}
.trg-panel__range input {
    flex: 1;
    border: 1px solid #282460;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: var(--font-heading);
    outline: none;
    width: 80px;
    color: #282460;
}
.trg-panel__range input:focus { border-color: #282460; }

.trg-filter-note {
    font-size: 9px;
    color: #999;
    font-style: italic;
    margin-top: 3px;
}

.trg-panel__loading {
    text-align: center;
    padding: 32px 0;
    color: #999;
    font-size: 12px;
    font-family: var(--font-heading);
}

.trg-panel__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid rgba(0,0,0,0.08);
}
.trg-panel__clear {
    background: none;
    border: none;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    padding: 6px 12px;
    text-decoration: underline;
}
.trg-panel__clear:hover { color: #282460; }
.trg-panel__show {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    background: #282460;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.trg-panel__show:hover { opacity: 0.9; }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.trg-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
}
.trg-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #282460;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #282460;
    background: #fff;
    cursor: pointer;
    font-family: var(--font-heading);
    text-decoration: none;
}
.trg-page-btn:hover { background: #282460; color: #fff; }
.trg-page-btn.active { background: #282460; color: #fff; border-color: #282460; }
.trg-page-btn.prev-next { width: auto; padding: 0 12px; }
.trg-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 11px;
    color: #282460;
    font-family: var(--font-heading);
    user-select: none;
}

/* ── Sort row adjustments ───────────────────────────────────────────────────── */
.building-listings__sort .trg-cap {
    text-decoration: none;
}

/* ── Clear filters button ───────────────────────────────────────────────────── */
.trg-clear-filters {
    background: none;
    border: none;
    color: #282460;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    text-decoration: underline;
    padding: 0 4px;
    white-space: nowrap;
}
.trg-clear-filters:hover {
    color: #FE8100;
}

/* ── View toggle (in listing header) ────────────────────────────────────────── */
.building-listings__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0 4px;
    flex-wrap: wrap;
}

.trg-listing-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.building-listings__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.trg-view-toggle {
    font-size: 11px;
    padding: 3px 12px;
}

/* ── Map view split layout ─────────────────────────────────────────────────── */
.trg-map-view-container {
    display: none;
    position: relative;
}
.trg-map-view-container.active {
    display: flex;
    gap: 0;
    min-height: 600px;
}
.trg-map-pane {
    width: 58%;
    position: sticky;
    top: var(--header-height, 72px);
    height: calc(100vh - var(--header-height, 72px));
}
.trg-community-map {
    width: 100%;
    height: 100%;
}
.trg-list-pane {
    width: 42%;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height, 72px));
    padding: 16px 20px;
}
.trg-list-pane__header {
    margin-bottom: 6px;
}
.trg-list-pane__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
/* ── Unified map view layout: pixel-match community-page.php ────────────── */
/* search-layout in map view uses same 58/42 split, padding, and grid as
   community-page's trg-map-view-container / trg-list-pane. */
.search-layout:not(.search-layout--grid-only) {
    grid-template-columns: 58fr 42fr;
    gap: 0;
    position: relative;
}
.search-layout:not(.search-layout--grid-only) .search-layout__map {
    height: calc(100vh - var(--header-height, 72px));
    top: var(--header-height, 72px);
}
.search-layout:not(.search-layout--grid-only) .search-layout__results {
    padding: 8px 20px;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height, 72px));
}
.search-layout:not(.search-layout--grid-only) .building-listings__header {
    margin-bottom: 6px;
}
.search-layout:not(.search-layout--grid-only) .building-listings__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.trg-list-pane .listing-card.is-highlighted {
    outline: 2px solid #FE8100;
    outline-offset: -2px;
    border-radius: var(--border-radius-lg, 8px);
}

/* ── Save This Search button ─────────────────────────────────────────── */
.trg-save-search-btn {
    background: var(--trg-orange, #FE8100);
    color: #fff;
    border-color: var(--trg-orange, #FE8100);
    font-weight: 600;
}

.trg-save-search-btn:hover,
.trg-save-search-btn:focus-visible {
    background: #e57200;
    border-color: #e57200;
    color: #fff;
}

/* When no filters are active, show in navy instead of orange */
.trg-save-search-btn.is-default {
    background: var(--trg-navy, #0a1f44);
    color: #fff;
    border-color: var(--trg-navy, #0a1f44);
}

.trg-save-search-btn.is-default:hover {
    background: #1a3a6e;
    border-color: #1a3a6e;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .trg-filter-bar__inner {
        padding: 4px var(--container-pad, 12px);
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .trg-panel {
        width: 100vw;
        max-width: 100vw;
    }
    .trg-popover {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
        min-width: auto;
        max-height: 60vh;
        overflow-y: auto;
    }
    .trg-map-view-container.active {
        flex-direction: column;
    }
    .trg-map-pane {
        width: 100%;
        height: 60vh;
        position: relative;
    }
    .trg-list-pane {
        width: 100%;
        max-height: none;
        overflow-y: visible;
    }
    .trg-list-pane__grid {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
        padding-bottom: 8px;
    }
    .trg-list-pane__grid .listing-card {
        min-width: 260px;
        flex-shrink: 0;
    }
}
