/* ==========================================================================
   Phase 5: Search UI Split-Screen Luxury Redesign (Zillow/Redfin Style)
   ========================================================================== */

/* App Wrapper */
.tbg-idx-search-app {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    /* Adjust based on WP header */
    min-height: 800px;
    font-family: var(--tbg-idx-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
    background: #fdfdfd !important;
    background-image: none !important;
    /* Hide weird theme bg */
    box-sizing: border-box;
    overflow: hidden;
    /* Prevent body scroll from app contents */
    z-index: 99;
    /* Sit over the top header backgrounds if needed */
}

/* "More Filters" outline button */
.tbg-idx-btn-more-filters {
    padding: 10px 16px;
    background: transparent;
    color: #0073e1;
    border: 1px solid #0073e1;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tbg-idx-btn-more-filters:hover {
    background: rgba(0, 115, 225, 0.08);
}

/* Advanced Filters Panel */
.tbg-idx-advanced-filters {
    padding: 12px 24px 4px;
    background: #f8f9fa;
    border-top: 1px solid #e8e8e8;
    position: relative;
    z-index: 20;
}

.tbg-idx-advanced-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.tbg-idx-advanced-grid .tbg-idx-filter-group select,
.tbg-idx-advanced-grid .tbg-idx-filter-range input {
    font-size: 14px;
    padding: 8px 10px;
}

.tbg-idx-advanced-grid .tbg-idx-filter-range input {
    width: 80px;
}

/* --------------------------------------
   Top Filter Bar
   -------------------------------------- */
.tbg-idx-filter-bar {
    flex: 0 0 auto;
    padding: 12px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    z-index: 20;
}

.tbg-idx-search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.tbg-idx-filter-group {
    position: relative;
    display: flex;
    align-items: center;
}

.tbg-idx-filter-omnibox {
    flex: 1 1 300px;
}

.tbg-idx-input-icon {
    position: relative;
    width: 100%;
}

.tbg-idx-input-icon svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
}

.tbg-idx-input-icon input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: box-shadow 0.2s;
}

.tbg-idx-input-icon input:focus,
.tbg-idx-filter-group select:focus,
.tbg-idx-filter-range input:focus {
    border-color: #0073e1;
    box-shadow: 0 0 0 3px rgba(0, 115, 225, 0.15);
}

.tbg-idx-filter-group select {
    padding: 10px 32px 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    outline: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%236b7280" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.tbg-idx-filter-range {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0 4px;
}

.tbg-idx-filter-range input {
    width: 90px;
    padding: 10px 8px;
    border: none;
    background: transparent;
    font-size: 15px;
    outline: none;
    text-align: center;
}

.tbg-idx-filter-range input::-webkit-outer-spin-button,
.tbg-idx-filter-range input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tbg-idx-range-sep {
    color: #9ca3af;
    pointer-events: none;
}

.tbg-idx-btn-search {
    padding: 10px 24px;
    background: #0073e1;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.tbg-idx-btn-search:hover {
    background: #005bb5;
}

.tbg-idx-btn-reset {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: transparent;
    color: var(--tbg-idx-text-color-muted, #777);
    border: 1px solid var(--tbg-idx-border-color, rgba(128,128,128,0.25));
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.tbg-idx-btn-reset:hover {
    background: rgba(128,128,128,0.1);
    color: var(--tbg-idx-text-color, #333);
    border-color: var(--tbg-idx-text-color-muted, #999);
}
.tbg-idx-filter-submit {
    display: flex;
    gap: 6px;
    align-items: center;
}


/* --------------------------------------
   Split Layout (List & Map)
   -------------------------------------- */
.tbg-idx-split-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Left Panel: Scrollable List */
.tbg-idx-list-panel {
    flex: 0 0 55%;
    max-width: 55%;
    overflow-y: auto;
    padding: 24px;
    background: #f8f9fa;
    position: relative;
}

.tbg-idx-list-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.tbg-idx-list-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #111;
}

.tbg-idx-list-meta {
    font-size: 14px;
    color: #555;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tbg-idx-btn-save-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: transparent;
    color: #0073e1;
    border: 1px solid #0073e1;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.tbg-idx-btn-save-search:hover {
    background: rgba(0, 115, 225, 0.08);
}

.tbg-idx-btn-save-search:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tbg-idx-btn-save-search.is-saved {
    color: #059669;
    border-color: #059669;
    background: rgba(5, 150, 105, 0.08);
}

.tbg-idx-grid-luxury {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Right Panel: Sticky Map */
.tbg-idx-map-panel {
    flex: 1 1 0%;
    position: relative;
    border-left: 1px solid #e0e0e0;
    min-height: 500px;
    z-index: 10;
}

.tbg-idx-map-full {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: inherit;
    z-index: 1;
}

/* Force Leaflet container to stay below overlay buttons */
.tbg-idx-map-panel .leaflet-container {
    z-index: 1;
}

.tbg-idx-map-panel .tbg-idx-search-area-btn,
.tbg-idx-map-panel .tbg-idx-map-overlay-btn {
    z-index: 9999;
    position: absolute;
    pointer-events: auto;
}

/* Map Toggle Overlay Button (floats on top of the map) */
.tbg-idx-map-overlay-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    padding: 8px 16px;
    background: #ffffff;
    color: #333;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
}

.tbg-idx-map-overlay-btn:hover {
    background: #f3f4f6;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Map Toggle Button (filter bar variant) */
.tbg-idx-map-toggle-group {
    margin-left: auto;
    /* Push to far right */
}

.tbg-idx-btn-outline {
    padding: 10px 16px;
    background: transparent;
    color: #0073e1;
    border: 1px solid #0073e1;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tbg-idx-btn-outline:hover {
    background: rgba(0, 115, 225, 0.1);
}

/* Hidden Map State */
.tbg-idx-split-layout.is-map-hidden .tbg-idx-map-panel {
    display: none;
}

.tbg-idx-split-layout.is-map-hidden .tbg-idx-list-panel {
    flex: 0 0 100%;
    max-width: 100%;
}

/* When map is hidden, restyle the toggle button as a blue "Show Map" CTA */
.tbg-idx-split-layout.is-map-hidden .tbg-idx-map-overlay-btn {
    background: #0073e1;
    color: #fff;
    border-color: #0073e1;
}

.tbg-idx-split-layout.is-map-hidden .tbg-idx-map-overlay-btn:hover {
    background: #005bb5;
}


/* --------------------------------------
   Luxury Listing Card 
   -------------------------------------- */
.tbg-idx-luxury-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #ebebeb;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.tbg-idx-luxury-card:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
    z-index: 2;
}

.tbg-idx-lc-image-wrap {
    position: relative;
    aspect-ratio: 4/3;
    background: #eaebed;
    overflow: hidden;
}

.tbg-idx-lc-img-link {
    display: block;
    width: 100%;
    height: 100%;
}

.tbg-idx-lc-img-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.tbg-idx-luxury-card:hover .tbg-idx-lc-img-link img {
    transform: scale(1.05);
}

.tbg-idx-lc-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a0a0a0;
}

.tbg-idx-lc-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.tbg-idx-lc-badge {
    background: #ffffff;
    color: #111;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tbg-idx-lc-badge.status-sold,
.tbg-idx-lc-badge.status-closed {
    background: #d32f2f;
    color: #fff;
}

.tbg-idx-lc-badge.status-pending {
    background: #f57c00;
    color: #fff;
}

.tbg-idx-lc-badge.badge-new {
    background: #0073e1;
    color: #fff;
}

.tbg-idx-lc-actions {
    position: absolute;
    top: 12px;
    right: 12px;
}

.tbg-idx-lc-fav-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.tbg-idx-lc-fav-btn:hover {
    transform: scale(1.1);
}

.tbg-idx-lc-content {
    padding: 16px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.tbg-idx-lc-price {
    font-size: 22px;
    font-weight: 700;
    color: #111;
    margin-bottom: 4px;
    line-height: 1.2;
}

.tbg-idx-lc-stats {
    display: flex;
    gap: 8px;
    font-size: 14px;
    color: #444;
    margin-bottom: 8px;
    align-items: center;
}

.tbg-idx-lc-stats span strong {
    color: #111;
    font-weight: 700;
}

.tbg-idx-lc-stat-lot {
    color: #666;
}

.tbg-idx-lc-address {
    font-size: 14px;
    color: #555;
    line-height: 1.4;
    margin-bottom: 12px;
}

.tbg-idx-lc-brokerage {
    margin-top: auto;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* --------------------------------------
   Loading, Empty State & Pagination
   -------------------------------------- */
.tbg-idx-loading-overlay {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 249, 250, 0.8);
    backdrop-filter: blur(4px);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.idx-spinner-luxury {
    border: 3px solid rgba(0, 115, 225, 0.2);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border-left-color: #0073e1;
    animation: idx-spin 1s linear infinite;
}

@keyframes idx-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.tbg-idx-empty-state {
    padding: 80px 20px;
    text-align: center;
    color: #666;
    background: #fff;
    border-radius: 12px;
    border: 1px dashed #ccc;
    margin-top: 20px;
}

.tbg-idx-empty-state svg {
    color: #999;
    margin-bottom: 16px;
}

.tbg-idx-empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: #333;
}

.tbg-idx-empty-state p {
    margin: 0;
    font-size: 15px;
}

.tbg-idx-pagination-luxury {
    margin-top: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
}

.tbg-idx-page-btn {
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.tbg-idx-page-btn:hover {
    border-color: #0073e1;
    color: #0073e1;
}

.tbg-idx-page-info {
    font-size: 14px;
    color: #6b7280;
}

.tbg-idx-footer-disclaimer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
    color: #999;
    text-align: center;
    line-height: 1.5;
}

/* --------------------------------------
   Map: "Search this area" Button
   -------------------------------------- */
.tbg-idx-search-area-btn {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #d1d5db;
    border-radius: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    pointer-events: auto;
    animation: idx-search-area-in 0.3s ease;
}

.tbg-idx-search-area-btn:hover {
    background: #0073e1;
    color: #fff;
    border-color: #0073e1;
    box-shadow: 0 6px 20px rgba(0, 115, 225, 0.3);
}

.tbg-idx-search-area-btn:hover svg {
    stroke: #fff;
}

.tbg-idx-search-area-btn:active {
    transform: translateX(-50%) scale(0.96);
}

@keyframes idx-search-area-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* --------------------------------------
   UX-7: Feature Dropdown
   -------------------------------------- */
.tbg-idx-features-dropdown {
    position: relative;
}

.tbg-idx-features-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tbg-idx-features-toggle:hover {
    border-color: #0073e1;
    color: #0073e1;
}

.tbg-idx-features-toggle.has-selections {
    border-color: #0073e1;
    color: #0073e1;
    background: rgba(0, 115, 225, 0.04);
}

.tbg-idx-features-toggle.is-open {
    border-color: #0073e1;
    box-shadow: 0 0 0 2px rgba(0, 115, 225, 0.15);
}

.tbg-idx-features-toggle .tbg-idx-chevron {
    transition: transform 0.2s ease;
}

.tbg-idx-features-toggle.is-open .tbg-idx-chevron {
    transform: rotate(180deg);
}

.tbg-idx-features-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #0073e1;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.tbg-idx-features-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 8px 0;
    animation: idx-dropdown-in 0.15s ease;
}

@keyframes idx-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tbg-idx-feature-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
    white-space: nowrap;
}

.tbg-idx-feature-check input[type="checkbox"] {
    display: none;
}

.tbg-idx-feature-check:hover {
    background: #f3f4f6;
}

.tbg-idx-feature-check.is-checked {
    background: rgba(0, 115, 225, 0.06);
    color: #0073e1;
}

.tbg-idx-feature-check.is-checked span::before {
    content: '✓ ';
    font-weight: 700;
}

/* --------------------------------------
   BUG-8: Error Toast
   -------------------------------------- */
.tbg-idx-error-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    animation: idx-toast-in 0.3s ease;
}

.tbg-idx-error-toast.is-fading {
    opacity: 0;
    transition: opacity 0.5s ease;
}

@keyframes idx-toast-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --------------------------------------
   Responsive Adjustments
   -------------------------------------- */
@media (max-width: 1024px) {
    .tbg-idx-search-app {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .tbg-idx-split-layout {
        flex-direction: column-reverse;
        overflow: visible;
    }

    .tbg-idx-map-panel {
        flex: none;
        height: 400px;
        /* Fixed height map on mobile */
        border-left: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .tbg-idx-map-full {
        position: relative;
    }

    .tbg-idx-list-panel {
        flex: 0 0 auto;
        max-width: 100%;
        overflow-y: visible;
    }
}

/* UX-6: Mobile filter bar improvements */
@media (max-width: 768px) {
    .tbg-idx-search-form {
        flex-direction: column;
        gap: 8px;
    }

    .tbg-idx-filter-omnibox {
        flex: 1 1 100%;
    }

    .tbg-idx-filter-group select,
    .tbg-idx-filter-range {
        width: 100%;
    }

    .tbg-idx-filter-range input {
        flex: 1;
    }

    .tbg-idx-filter-submit {
        width: 100%;
        justify-content: stretch;
        gap: 8px;
    }

    .tbg-idx-filter-submit .tbg-idx-btn-search,
    .tbg-idx-filter-submit .tbg-idx-btn-more-filters {
        flex: 1;
    }

    .tbg-idx-advanced-grid {
        flex-direction: column;
    }

    .tbg-idx-advanced-grid .tbg-idx-filter-group,
    .tbg-idx-advanced-grid .tbg-idx-filter-range {
        width: 100%;
    }

    .tbg-idx-features-dropdown {
        width: 100%;
    }

    .tbg-idx-features-toggle {
        width: 100%;
        justify-content: center;
    }

    .tbg-idx-features-panel {
        width: 100%;
        left: 0;
        right: 0;
    }
}

/* ==========================================================================
   BUG-S5 + BUG-S7: Dark Mode Overrides — Search Page
   ========================================================================== */

[data-theme="dark"] .tbg-idx-search-app,
.dark .tbg-idx-search-app {
    background: #0f1115 !important;
}

/* Filter Bar */
[data-theme="dark"] .tbg-idx-filter-bar,
.dark .tbg-idx-filter-bar {
    background: #161b22;
    border-bottom-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .tbg-idx-filter-group select,
.dark .tbg-idx-filter-group select {
    background-color: #1c2128;
    color: #e6edf3;
    border-color: rgba(255, 255, 255, 0.12);
    background-image: url('data:image/svg+xml;utf8,<svg fill="%239ca3af" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
}

[data-theme="dark"] .tbg-idx-filter-group select option,
.dark .tbg-idx-filter-group select option {
    background: #1c2128;
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-input-icon input,
.dark .tbg-idx-input-icon input {
    background: #1c2128;
    color: #e6edf3;
    border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .tbg-idx-input-icon input::placeholder,
.dark .tbg-idx-input-icon input::placeholder {
    color: #6b7280;
}

[data-theme="dark"] .tbg-idx-input-icon svg,
.dark .tbg-idx-input-icon svg {
    color: #6b7280;
}

[data-theme="dark"] .tbg-idx-filter-range,
.dark .tbg-idx-filter-range {
    background: #1c2128;
    border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .tbg-idx-filter-range input,
.dark .tbg-idx-filter-range input {
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-filter-range input::placeholder,
.dark .tbg-idx-filter-range input::placeholder {
    color: #6b7280;
}

[data-theme="dark"] .tbg-idx-range-sep,
.dark .tbg-idx-range-sep {
    color: #4b5563;
}

/* Focus states */
[data-theme="dark"] .tbg-idx-input-icon input:focus,
[data-theme="dark"] .tbg-idx-filter-group select:focus,
[data-theme="dark"] .tbg-idx-filter-range input:focus,
.dark .tbg-idx-input-icon input:focus,
.dark .tbg-idx-filter-group select:focus,
.dark .tbg-idx-filter-range input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Search & Outline Buttons */
[data-theme="dark"] .tbg-idx-btn-search,
.dark .tbg-idx-btn-search {
    background: #3b82f6;
}

[data-theme="dark"] .tbg-idx-btn-search:hover,
.dark .tbg-idx-btn-search:hover {
    background: #2563eb;
}

[data-theme="dark"] .tbg-idx-btn-outline,
[data-theme="dark"] .tbg-idx-btn-more-filters,
.dark .tbg-idx-btn-outline,
.dark .tbg-idx-btn-more-filters {
    color: #60a5fa;
    border-color: #60a5fa;
}

[data-theme="dark"] .tbg-idx-btn-outline:hover,
[data-theme="dark"] .tbg-idx-btn-more-filters:hover,
.dark .tbg-idx-btn-outline:hover,
.dark .tbg-idx-btn-more-filters:hover {
    background: rgba(96, 165, 250, 0.1);
}

/* Advanced Filters Panel */
[data-theme="dark"] .tbg-idx-advanced-filters,
.dark .tbg-idx-advanced-filters {
    background: #131920;
    border-top-color: rgba(255, 255, 255, 0.06);
}

/* List Panel */
[data-theme="dark"] .tbg-idx-list-panel,
.dark .tbg-idx-list-panel {
    background: #0f1115;
}

[data-theme="dark"] .tbg-idx-list-title,
.dark .tbg-idx-list-title {
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-list-meta,
[data-theme="dark"] .tbg-idx-results-count,
.dark .tbg-idx-list-meta,
.dark .tbg-idx-results-count {
    color: #9ca3af;
}

/* Save Search Button */
[data-theme="dark"] .tbg-idx-btn-save-search,
.dark .tbg-idx-btn-save-search {
    color: #60a5fa;
    border-color: #60a5fa;
}

[data-theme="dark"] .tbg-idx-btn-save-search:hover,
.dark .tbg-idx-btn-save-search:hover {
    background: rgba(96, 165, 250, 0.1);
}

[data-theme="dark"] .tbg-idx-btn-save-search.is-saved,
.dark .tbg-idx-btn-save-search.is-saved {
    color: #34d399;
    border-color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

/* Listing Cards */
[data-theme="dark"] .tbg-idx-luxury-card,
.dark .tbg-idx-luxury-card {
    background: #161b22;
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .tbg-idx-luxury-card:hover,
.dark .tbg-idx-luxury-card:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tbg-idx-lc-price,
.dark .tbg-idx-lc-price {
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-lc-stats,
.dark .tbg-idx-lc-stats {
    color: #9ca3af;
}

[data-theme="dark"] .tbg-idx-lc-stats span strong,
.dark .tbg-idx-lc-stats span strong {
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-lc-address,
.dark .tbg-idx-lc-address {
    color: #9ca3af;
}

[data-theme="dark"] .tbg-idx-lc-brokerage,
.dark .tbg-idx-lc-brokerage {
    color: #6b7280;
}

[data-theme="dark"] .tbg-idx-lc-content,
.dark .tbg-idx-lc-content {
    color: #e6edf3;
}

/* Loading Overlay */
[data-theme="dark"] .tbg-idx-loading-overlay,
.dark .tbg-idx-loading-overlay {
    background: rgba(15, 17, 21, 0.8);
}

[data-theme="dark"] .idx-spinner-luxury,
.dark .idx-spinner-luxury {
    border-color: rgba(59, 130, 246, 0.2);
    border-left-color: #3b82f6;
}

/* Empty State */
[data-theme="dark"] .tbg-idx-empty-state,
.dark .tbg-idx-empty-state {
    background: #161b22;
    border-color: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
}

[data-theme="dark"] .tbg-idx-empty-state h3,
.dark .tbg-idx-empty-state h3 {
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-empty-state svg,
.dark .tbg-idx-empty-state svg {
    color: #6b7280;
}

/* Pagination */
[data-theme="dark"] .tbg-idx-page-btn,
.dark .tbg-idx-page-btn {
    background: #1c2128;
    border-color: rgba(255, 255, 255, 0.12);
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-page-btn:hover,
.dark .tbg-idx-page-btn:hover {
    border-color: #3b82f6;
    color: #60a5fa;
}

[data-theme="dark"] .tbg-idx-page-info,
.dark .tbg-idx-page-info {
    color: #9ca3af;
}

/* Footer Disclaimer */
[data-theme="dark"] .tbg-idx-footer-disclaimer,
.dark .tbg-idx-footer-disclaimer {
    border-top-color: rgba(255, 255, 255, 0.06);
    color: #6b7280;
}

/* Map Panel Border */
[data-theme="dark"] .tbg-idx-map-panel,
.dark .tbg-idx-map-panel {
    border-left-color: rgba(255, 255, 255, 0.06);
}

/* Map Toggle Overlay Button */
[data-theme="dark"] .tbg-idx-map-overlay-btn,
.dark .tbg-idx-map-overlay-btn {
    background: #1c2128;
    color: #e6edf3;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .tbg-idx-map-overlay-btn:hover,
.dark .tbg-idx-map-overlay-btn:hover {
    background: #242c38;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tbg-idx-split-layout.is-map-hidden .tbg-idx-map-overlay-btn,
.dark .tbg-idx-split-layout.is-map-hidden .tbg-idx-map-overlay-btn {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* Search This Area Button */
[data-theme="dark"] .tbg-idx-search-area-btn,
.dark .tbg-idx-search-area-btn {
    background: rgba(22, 27, 34, 0.95);
    border-color: rgba(255, 255, 255, 0.12);
    color: #e6edf3;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .tbg-idx-search-area-btn:hover,
.dark .tbg-idx-search-area-btn:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* Feature Dropdown */
[data-theme="dark"] .tbg-idx-features-toggle,
.dark .tbg-idx-features-toggle {
    background: #1c2128;
    color: #e6edf3;
    border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .tbg-idx-features-toggle:hover,
.dark .tbg-idx-features-toggle:hover {
    border-color: #60a5fa;
    color: #60a5fa;
}

[data-theme="dark"] .tbg-idx-features-toggle.has-selections,
.dark .tbg-idx-features-toggle.has-selections {
    border-color: #3b82f6;
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.08);
}

[data-theme="dark"] .tbg-idx-features-toggle.is-open,
.dark .tbg-idx-features-toggle.is-open {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .tbg-idx-features-panel,
.dark .tbg-idx-features-panel {
    background: #1c2128;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tbg-idx-feature-check,
.dark .tbg-idx-feature-check {
    color: #e6edf3;
}

[data-theme="dark"] .tbg-idx-feature-check:hover,
.dark .tbg-idx-feature-check:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .tbg-idx-feature-check.is-checked,
.dark .tbg-idx-feature-check.is-checked {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

/* Error Toast */
[data-theme="dark"] .tbg-idx-error-toast,
.dark .tbg-idx-error-toast {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.25);
    color: #f87171;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE COLLAPSIBLE FILTERS
   ═══════════════════════════════════════════════════════════════════════ */

/* Toggle button — hidden on desktop */
.tbg-idx-mobile-filter-toggle {
    display: none;
}

/* Collapsible wrapper — no effect on desktop */
.tbg-idx-mobile-collapsible {
    display: contents; /* transparent wrapper on desktop */
}

/* Dark Mode — Mobile Toggle */
[data-theme="dark"] .tbg-idx-mobile-filter-toggle,
.dark .tbg-idx-mobile-filter-toggle {
    background: #1c2128;
    color: #e6edf3;
    border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .tbg-idx-mobile-filter-toggle:hover,
.dark .tbg-idx-mobile-filter-toggle:hover {
    background: #242c38;
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .tbg-idx-mobile-filter-toggle[aria-expanded="true"],
.dark .tbg-idx-mobile-filter-toggle[aria-expanded="true"] {
    background: rgba(59, 130, 246, 0.12);
    border-color: #3b82f6;
    color: #60a5fa;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Search Page
   ═══════════════════════════════════════════════════════════════════════ */

/* Tablet (1024px) — begin responsive adjustments */
@media (max-width: 1024px) {
    .tbg-idx-list-panel {
        flex: 0 0 50%;
        max-width: 50%;
        padding: 16px;
    }

    .tbg-idx-filter-range input {
        width: 70px;
    }

    .tbg-idx-advanced-grid .tbg-idx-filter-range input {
        width: 65px;
    }
}

/* Tablet portrait / large phone (768px) — stack layout */
@media (max-width: 768px) {
    .tbg-idx-search-app {
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    .tbg-idx-split-layout {
        flex-direction: column;
        overflow: visible;
    }

    .tbg-idx-list-panel {
        flex: none;
        max-width: 100%;
        width: 100%;
        padding: 16px;
        overflow-y: visible;
        min-height: auto;
    }

    /* Hide map by default on mobile to prioritize listings */
    .tbg-idx-map-panel {
        flex: none;
        width: 100%;
        height: 350px;
        min-height: 350px;
        border-left: none;
        border-top: 1px solid #e0e0e0;
        order: -1;
        display: none;
    }

    .tbg-idx-split-layout .tbg-idx-map-overlay-btn {
        position: fixed;
        bottom: 16px;
        right: 16px;
        top: auto;
        z-index: 1000;
        border-radius: 24px;
        padding: 10px 18px;
        font-size: 13px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
        background: #0073e1;
        color: #fff;
        border-color: #0073e1;
    }

    /* When user explicitly shows map on mobile */
    .tbg-idx-split-layout:not(.is-map-hidden) .tbg-idx-map-panel {
        display: block;
    }

    .tbg-idx-map-full {
        position: relative;
        height: 350px;
        min-height: 350px;
    }

    /* ---- Collapsible Filter Toggle ---- */
    .tbg-idx-mobile-filter-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 10px 16px;
        background: #fff;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 600;
        color: #374151;
        cursor: pointer;
        transition: all 0.2s ease;
        font-family: inherit;
        line-height: 1.4;
        order: 1;
    }

    .tbg-idx-mobile-filter-toggle:hover {
        border-color: #0073e1;
        color: #0073e1;
    }

    .tbg-idx-mobile-filter-toggle[aria-expanded="true"] {
        background: rgba(0, 115, 225, 0.06);
        border-color: #0073e1;
        color: #0073e1;
    }

    .tbg-idx-mobile-filter-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        background: #0073e1;
        color: #fff;
        border-radius: 10px;
        font-size: 11px;
        font-weight: 700;
        line-height: 1;
    }

    .tbg-idx-mobile-chevron {
        transition: transform 0.25s ease;
        margin-left: auto;
    }

    .tbg-idx-mobile-filter-toggle[aria-expanded="true"] .tbg-idx-mobile-chevron {
        transform: rotate(180deg);
    }

    /* ---- Collapsible Wrapper ---- */
    .tbg-idx-mobile-collapsible {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.25s ease,
                    padding 0.3s ease;
        opacity: 0;
        order: 2;
    }

    .tbg-idx-mobile-collapsible.is-expanded {
        max-height: 2000px; /* generous upper bound */
        opacity: 1;
        padding-top: 8px;
    }

    /* Keep omnibox as order 0 so it appears first */
    .tbg-idx-filter-omnibox {
        order: 0;
        flex: 1 1 100%;
    }

    .tbg-idx-map-overlay-btn {
        top: 8px;
        right: 8px;
        font-size: 12px;
        padding: 6px 12px;
    }

    /* Filter Bar: Stack vertically */
    .tbg-idx-filter-bar {
        padding: 10px 12px;
    }

    .tbg-idx-search-form {
        gap: 8px;
    }

    .tbg-idx-filter-omnibox {
        flex: 1 1 100%;
    }

    .tbg-idx-filter-group select {
        font-size: 13px;
        padding: 8px 28px 8px 10px;
    }

    .tbg-idx-filter-range input {
        width: 65px;
        font-size: 13px;
        padding: 8px 6px;
    }

    .tbg-idx-input-icon input {
        font-size: 14px;
        padding: 9px 12px 9px 36px;
    }

    .tbg-idx-btn-search {
        font-size: 13px;
        padding: 8px 16px;
    }

    .tbg-idx-btn-reset {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* Advanced Filters */
    .tbg-idx-advanced-filters {
        padding: 8px 12px 4px;
    }

    .tbg-idx-advanced-grid {
        gap: 8px;
    }

    /* List header */
    .tbg-idx-list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 16px;
    }

    .tbg-idx-list-title {
        font-size: 18px;
    }

    .tbg-idx-list-meta {
        font-size: 12px;
        gap: 8px;
    }

    /* Card grid — 2 columns on tablet */
    .tbg-idx-grid-luxury {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    /* Features dropdown — full width */
    .tbg-idx-features-dropdown {
        flex: 1 1 100%;
    }

    /* Search area button */
    .tbg-idx-search-area-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    /* Footer disclaimer */
    .tbg-idx-footer-disclaimer {
        font-size: 11px;
    }
}

/* Phone (480px) — single column, touch-optimized */
@media (max-width: 480px) {
    .tbg-idx-search-app {
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
    }

    .tbg-idx-filter-bar {
        padding: 8px;
    }

    .tbg-idx-search-form {
        gap: 6px;
    }

    .tbg-idx-filter-group select {
        font-size: 13px;
        padding: 9px 28px 9px 10px;
        flex: 1;
    }

    .tbg-idx-filter-range {
        flex: 1 1 100%;
    }

    .tbg-idx-filter-range input {
        width: auto;
        flex: 1;
        font-size: 13px;
    }

    .tbg-idx-btn-search {
        flex: 1;
        text-align: center;
        padding: 10px;
    }

    .tbg-idx-filter-submit {
        flex: 1 1 100%;
    }

    /* Advanced filters grid stacks */
    .tbg-idx-advanced-grid {
        flex-direction: column;
        align-items: stretch;
    }

    .tbg-idx-advanced-grid .tbg-idx-filter-group {
        width: 100%;
    }

    .tbg-idx-advanced-grid .tbg-idx-filter-range {
        width: 100%;
    }

    .tbg-idx-advanced-grid .tbg-idx-filter-range input {
        width: auto;
        flex: 1;
    }

    .tbg-idx-advanced-grid .tbg-idx-filter-group select {
        width: 100%;
    }

    /* List panel */
    .tbg-idx-list-panel {
        padding: 12px;
    }

    /* Card grid — single column */
    .tbg-idx-grid-luxury {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .tbg-idx-list-title {
        font-size: 16px;
    }

    /* Map panel — smaller */
    .tbg-idx-map-panel {
        height: 250px;
        min-height: 250px;
    }

    .tbg-idx-map-full {
        height: 250px;
        min-height: 250px;
    }

    /* Pagination */
    .tbg-idx-pagination-luxury {
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* Extra small (375px and below) */
@media (max-width: 375px) {
    .tbg-idx-filter-bar {
        padding: 6px;
    }

    .tbg-idx-list-panel {
        padding: 8px;
    }

    .tbg-idx-list-title {
        font-size: 15px;
    }

    .tbg-idx-grid-luxury {
        gap: 12px;
    }
}