/* ==============================================
   LAYOUT - Property Search
   Clean, efficient layout with proper dark mode
   ============================================== */

/* ----- Body Setup ----- */
.search-page-body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

.search-page-body .site-footer,
.search-page-body .site-main>.messages-container {
    display: none !important;
}

/* ----- Main Container ----- */
.search-layout-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-top: var(--navbar-height, 56px);
    background: var(--bg-primary, #fff);
}

/* ----- Filters Bar ----- */
.search-filters-bar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-light, #ebebeb);
    background: var(--bg-primary, #fff);
    z-index: 50;
    /* Slightly reduce padding for more content space */
    padding-top: 6px;
    padding-bottom: 6px;
}

/* ----- Split View ----- */
.search-split-view {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ----- List Column (Desktop) ----- */
.search-list-column {
    width: 55%;
    max-width: 840px;
    height: 100%;
    overflow-y: auto;
    padding: 20px 24px 100px;
    background: var(--bg-primary, #fff);
    z-index: 10;
    scroll-behavior: smooth;
    order: 1;
}

.search-list-column::-webkit-scrollbar {
    width: 6px;
}

.search-list-column::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

/* Drawer handle - hidden on desktop */
.drawer-handle {
    display: none;
}

.search-list-header {
    margin-bottom: 16px;
}

.results-count {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #717171);
    margin: 0;
}

/* ----- Map Column ----- */
.search-map-column {
    flex: 1;
    height: 100%;
    position: sticky;
    top: 0;
    background: #e5e3df;
    order: 2;
}

/* ----- Properties Grid ----- */
.properties-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px 20px;
}

/* No Results */
.no-results {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    text-align: center;
}

/* Pagination */
.search-pagination {
    margin-top: 40px;
    padding: 20px 0;
}

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.page-link {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--text-primary, #222);
    border-radius: 50%;
    color: var(--text-primary, #222);
    text-decoration: none;
    transition: all 0.2s;
}

.page-link:hover {
    background: var(--text-primary, #222);
    color: var(--bg-primary, #fff);
}

/* Hidden toggle */
.mobile-map-toggle {
    display: none;
}

/* ==============================================
   TABLET
   ============================================== */

@media (max-width: 1024px) {
    .search-list-column {
        width: 50%;
        padding: 16px 16px 100px;
    }

    .properties-grid {
        gap: 18px 12px;
    }
}

/* ==============================================
   MOBILE - Bottom Sheet Drawer
   ============================================== */

@media (max-width: 768px) {
    .search-layout-container {
        padding-top: 0;
        position: relative;
    }

    /* Floating filter bar - Position below navbar */
    .search-filters-bar {
        position: fixed;
        top: calc(var(--navbar-height-mobile, 50px) + 8px);
        left: 8px;
        right: 8px;
        z-index: 9999; /* Below navbar (10000) but above content */
        background: transparent;
        border: none;
        pointer-events: none;
    }
    
    .search-filters-bar .search-filters-container {
        pointer-events: auto;
    }

    .search-split-view {
        height: 100%;
        position: relative;
    }

    /* Map behind */
    .search-map-column {
        position: absolute;
        inset: 0;
        z-index: 1;
    }

    /* Drawer */
    .search-list-column {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        height: 45%;
        max-height: 100%;
        min-height: 100px;
        z-index: 50;
        order: unset;

        background: var(--bg-primary, #fff);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);

        overflow: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;

        padding: 0;
        display: flex;
        flex-direction: column;

        /* Smooth drag - no transition during drag */
        will-change: height, transform;
    }

    /* Transition only when not dragging */
    .search-list-column:not(.dragging) {
        transition: height 0.35s cubic-bezier(0.32, 0.72, 0, 1),
            border-radius 0.2s ease;
    }

    /* States */
    .search-list-column.fullscreen {
        height: 100% !important;
        border-radius: 0;
    }
    
    .search-list-column.expanded {
        height: 75%;
    }

    .search-list-column.collapsed {
        height: 100px;
    }
    
    .search-list-column.collapsed .properties-grid-wrapper {
        overflow: hidden;
    }

    /* Drawer Handle */
    .drawer-handle {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px 0 8px;
        cursor: grab;
        touch-action: none; /* Prevent scrolling on handle */
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        flex-shrink: 0;
        background: var(--bg-primary, #fff);
        border-radius: 16px 16px 0 0;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .drawer-handle:active {
        cursor: grabbing;
    }
    
    /* Prevent text selection during drag */
    .search-list-column.dragging {
        -webkit-user-select: none;
        user-select: none;
    }

    .drawer-handle::after {
        content: '';
        width: 40px;
        height: 5px;
        background: var(--border-color, #ddd);
        border-radius: 3px;
        transition: background 0.2s;
    }
    
    .drawer-handle:hover::after,
    .drawer-handle:active::after {
        background: var(--text-secondary, #999);
    }

    /* Sticky header */
    .search-list-header {
        flex-shrink: 0;
        text-align: center;
        margin: 0;
        padding: 4px 16px 12px;
        background: var(--bg-primary, #fff);
        position: sticky;
        top: 0;
        z-index: 5;
    }

    .results-count {
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary, #222);
    }

    /* Grid wrapper - scrollable area */
    .properties-grid-wrapper {
        flex: 1;
        padding: 0 14px 120px;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Smooth scrolling */
    .properties-grid-wrapper::-webkit-scrollbar {
        width: 4px;
    }
    
    .properties-grid-wrapper::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }

    .properties-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    /* Visual feedback when expanded */
    .search-list-column.expanded .drawer-handle::after,
    .search-list-column.fullscreen .drawer-handle::after {
        width: 60px;
    }
}

/* ==============================================
   DARK MODE
   ============================================== */

[data-theme="dark"] .search-layout-container,
[data-theme="dark"] .search-list-column,
[data-theme="dark"] .search-filters-bar,
[data-theme="dark"] .drawer-handle,
[data-theme="dark"] .search-list-header {
    background: var(--bg-primary, #121212);
}

[data-theme="dark"] .search-list-column {
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .drawer-handle::after {
    background: var(--border-color, #444);
}

[data-theme="dark"] .results-count {
    color: var(--text-primary, #fff);
}

[data-theme="dark"] .page-link {
    border-color: var(--text-primary, #fff);
    color: var(--text-primary, #fff);
}

[data-theme="dark"] .page-link:hover {
    background: var(--text-primary, #fff);
    color: var(--bg-primary, #121212);
}