/* ============================================================
   SEARCH PAGE STICKY SIDEBAR FIXES
   Moved from inline styles in search.php for clean SEO
   ============================================================ */

/* ============================================================
   FEATURED PROPERTIES SECTION
   ============================================================ */

/* Featured properties section wrapper */
.featured-properties {
    margin-bottom: 48px;
    padding-bottom: 24px;
}

.featured-title {
    margin-bottom: 15px;
    font-size: 22px;
    font-weight: 600;
}

/* Featured list card spacing - same for all listings (override akkus.css) */
.search-page .featured-list .listing-card,
.search-page .featured-list li.listing-card,
.search-page .property-list--standard .listing-card,
.search-page .property-list--standard li.listing-card,
.search-page .property-list.property-list--standard .listing-card,
.search-page .property-list.property-list--standard li.listing-card {
    margin-bottom: 24px !important;
}

/* ============================================================
   LISTING SECTION TITLE
   ============================================================ */

/* Listing Section Title - "All Properties in {City}" */
.listing-section-title {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid #eee;
}

.listing-subtitle {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: #6b7280;
    margin-top: 4px;
}

/* ============================================================
   SEARCH PAGE ENHANCEMENTS
   ============================================================ */

/* Convert listing images from background-image to <img> tags */
.search-page .listing-card .listing-image .image {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4 / 3 !important;
    object-fit: cover !important;
    object-position: center center !important;
    display: block !important;
    background: none !important;
}

/* Results Header */
.search-results-header {
    margin-bottom: 20px;
    padding: 15px 0;
    border-bottom: 1px solid #e0e0e0;
}

.search-results-header .results-count {
    font-size: 16px;
    color: #333;
    margin-bottom: 15px;
}

.search-results-header .results-count strong {
    font-size: 20px;
    color: #08255d;
    font-weight: 700;
}

.search-results-header .showing-range {
    color: #666;
    font-size: 14px;
    margin-left: 8px;
}

/* Active Filter Chips */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.active-filters .filters-label {
    font-weight: 600;
    color: #333;
    margin-right: 5px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    background: #e8f4f8;
    border: 1px solid #60A2D0;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 14px;
    gap: 8px;
}

.filter-chip .filter-label {
    color: #08255d;
    font-weight: 500;
}

.filter-chip .filter-remove {
    color: #60A2D0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(96, 162, 208, 0.1);
    transition: background 0.2s;
}

.filter-chip .filter-remove:hover {
    background: rgba(96, 162, 208, 0.2);
    color: #08255d;
}

.clear-all-filters {
    color: #60A2D0;
    text-decoration: underline;
    font-size: 14px;
    margin-left: 10px;
}

.clear-all-filters:hover {
    color: #08255d;
}

/* Empty State */
.no-results {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 40px 0;
}

.no-results-content i {
    font-size: 64px;
    color: #ccc;
    margin-bottom: 20px;
    display: block;
}

.no-results-content h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 15px;
}

.no-results-content > p {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
}

.no-results-suggestions {
    text-align: left;
    max-width: 500px;
    margin: 0 auto 30px;
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.no-results-suggestions h3 {
    font-size: 18px;
    color: #08255d;
    margin-bottom: 15px;
}

.no-results-suggestions ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.no-results-suggestions li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: #555;
}

.no-results-suggestions li:before {
    content: "•";
    position: absolute;
    left: 10px;
    color: #60A2D0;
    font-weight: bold;
}

.btn-clear-search {
    display: inline-block;
    background: #08255d;
    color: #fff;
    padding: 12px 30px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-clear-search:hover {
    background: #0a377e;
    color: #fff;
}

/* Form Accessibility Improvements */
.search-page form#rfn {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-page form#rfn input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.search-page form#rfn button[type="submit"] {
    padding: 10px 20px;
    background: #08255d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.search-page form#rfn button[type="submit"]:hover {
    background: #0a377e;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Footer Wrapper - Full Width */
.search-page .footer-wrapper {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding: 0;
    overflow: hidden;
    margin-top: 80px !important;
}

/* Mobile Responsive Styles */
@media (max-width: 991px) {
    .search-results-header {
        padding: 10px 0;
    }
    
    .active-filters {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-chip {
        font-size: 13px;
    }
    
    .no-results {
        padding: 40px 15px;
    }
    
    .no-results-content i {
        font-size: 48px;
    }
    
    .no-results-content h2 {
        font-size: 24px;
    }
    
    .search-page form#rfn {
        flex-direction: column;
    }
    
    .search-page form#rfn button[type="submit"] {
        width: 100%;
        justify-content: center;
    }
    
    /* ============================================================
       MOBILE SIDEBAR FIX - FULL WIDTH ON MOBILE
       ============================================================ */
    .search-page .sidebar.right-sidebar,
    .search-page aside.sidebar.right-sidebar,
    .search-page .right-sidebar,
    .search-page .col-md-3.sidebar,
    .search-page .row > .col-md-3.sidebar,
    .search-page .row > .sidebar.right-sidebar,
    .search-page .row > aside.col-md-3,
    .search-page .container .row > .col-md-3,
    .search-page .container .row > .sidebar,
    .search-page .container .row > aside {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        flex: 0 0 100% !important;
        float: none !important;
        clear: both !important;
        position: relative !important;
        margin-top: 30px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        box-sizing: border-box !important;
        order: 2 !important; /* Sidebar appears after content */
    }
    
    /* Ensure sidebar content is full width */
    .search-page .sidebar.right-sidebar > *,
    .search-page .right-sidebar > *,
    .search-page .col-md-3.sidebar > * {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Article/content should also be full width on mobile and appear first */
    .search-page .col-md-9,
    .search-page article.col-md-9,
    .search-page .container .row > .col-md-9,
    .search-page .container .row > article {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        flex: 0 0 100% !important;
        float: none !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        box-sizing: border-box !important;
        order: 1 !important; /* Content appears first */
        margin-bottom: 0 !important;
    }
    
    /* Row should stack vertically on mobile */
    .search-page .container .row,
    .search-page .container > .row {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Override any Bootstrap or other CSS that might constrain width */
    .search-page .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
        max-width: 100% !important;
    }
}

/* Sticky sidebar for search page */
@media (min-width: 992px) {
    /* Ensure parent containers don't break sticky - HIGH SPECIFICITY */
    html.search-page .main,
    html.search-page #content,
    html.search-page .content.full,
    html.search-page .container,
    .search-page .main,
    .search-page #content,
    .search-page .content.full,
    .search-page .container {
        overflow: visible !important;
        height: auto !important;
        position: relative !important;
    }
    
    /* Make sure the row container allows sticky positioning - HIGH SPECIFICITY */
    html.search-page .container .row,
    html.search-page .main .content.full .container .row,
    .search-page .container .row,
    .search-page .main .content.full .container .row {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: flex-start !important;
        position: relative !important;
        overflow: visible !important;
        height: auto !important;
    }
    
    /* Ensure col-md-9 (article) is positioned correctly on LEFT - HIGH SPECIFICITY */
    html.search-page .col-md-9,
    html.search-page article.col-md-9,
    html.search-page .row > article.col-md-9,
    html.search-page .row > .col-md-9,
    .search-page .col-md-9,
    .search-page article.col-md-9,
    .search-page .row > article.col-md-9,
    .search-page .row > .col-md-9 {
        overflow: visible !important;
        float: none !important;
        clear: none !important;
        width: 75% !important;
        flex: 0 0 75% !important;
        max-width: 75% !important;
        position: relative !important;
        order: 1 !important;
    }
    
    /* Sticky sidebar - MUST be on the RIGHT side - HIGH SPECIFICITY */
    html.search-page .sidebar.right-sidebar,
    html.search-page aside.sidebar.right-sidebar,
    html.search-page .right-sidebar,
    html.search-page .col-md-3.sidebar,
    html.search-page .row > .col-md-3.sidebar,
    html.search-page .row > .sidebar.right-sidebar,
    html.search-page .row > aside.col-md-3,
    html.search-page aside.right-sidebar.col-md-3,
    html.search-page .col-md-3.right-sidebar,
    .search-page .sidebar.right-sidebar,
    .search-page aside.sidebar.right-sidebar,
    .search-page .right-sidebar,
    .search-page .col-md-3.sidebar,
    .search-page .row > .col-md-3.sidebar,
    .search-page .row > .sidebar.right-sidebar,
    .search-page .row > aside.col-md-3,
    .search-page aside.right-sidebar.col-md-3,
    .search-page .col-md-3.right-sidebar {
        position: sticky !important;
        top: 67px !important;
        z-index: 100 !important;
        height: max-content !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        align-self: flex-start !important;
        float: none !important;
        clear: none !important;
        width: 25% !important;
        max-width: 25% !important;
        flex: 0 0 25% !important;
        order: 2 !important;
    }
    
    /* Override any conflicting styles from style.css and akkus.css - HIGH SPECIFICITY */
    html.search-page .right-sidebar,
    html.search-page aside.right-sidebar,
    .search-page .right-sidebar,
    .search-page aside.right-sidebar {
        clear: none !important;
        margin-top: 0 !important;
        position: sticky !important;
        top: 67px !important;
        float: none !important;
    }
    
    /* Ensure col-md-3 wrapper allows sticky */
    html.search-page .col-md-3,
    html.search-page aside.col-md-3,
    html.search-page .sidebar.col-md-3,
    .search-page .col-md-3,
    .search-page aside.col-md-3,
    .search-page .sidebar.col-md-3 {
        overflow: visible !important;
        position: relative !important;
    }
    
    /* Prevent any conflicting styles */
    .search-page .sidebar.right-sidebar > * {
        position: static !important;
    }
    
    
    /* Ensure row uses flexbox properly */
    .search-page .row {
        display: flex !important;
        flex-direction: row !important;
    }
    
    /* Force column order */
    .search-page .row > article.col-md-9 {
        order: 1 !important;
        flex: 0 0 75% !important;
    }
    
    .search-page .row > aside.col-md-3,
    .search-page .row > .col-md-3.sidebar {
        order: 2 !important;
        flex: 0 0 25% !important;
    }
}

/* ============================================================
   ADVANTAGE PAGE MOBILE SPACING FIX
   Reduce logo to H1 distance on mobile
   ============================================================ */
@media (max-width: 991px) {
    /* Reduce top margin/padding for advantage page H1 */
    .advantage-page-h1 {
        margin-top: 10px !important;
        padding-top: 0 !important;
    }
    
    /* Reduce container top padding on mobile */
    .advantage-page-h1 + .advantages-filter-section {
        margin-top: 15px !important;
    }
    
    /* Ensure H1 is visible immediately after header */
    .main .content.full .container .row .col-md-9 .advantage-page-h1 {
        margin-top: 10px !important;
    }
}

/* ============================================================
   SORT DROPDOWN STYLING (Same as location.php)
   ============================================================ */
.sorting-wrapper {
    margin-top: 15px;
    margin-bottom: 20px;
}

@media (max-width: 767px) {
    .sorting-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .sort-dropdown {
        width: 100%;
    }
}

/* ============================================================
   LISTING COUNT STYLING (Replaces duplicate H2 counter)
   ============================================================ */
.listing-count {
    font-size: 16px;
    color: #666;
    margin-top: 20px;
    margin-bottom: 24px;
    font-weight: 400;
}

@media (max-width: 767px) {
    .listing-count {
        font-size: 14px;
        margin-top: 15px;
        margin-bottom: 20px;
    }
}

/* ============================================================
   CRITICAL OVERRIDE - Ensure sticky sidebar works on search page
   Maximum specificity to override any conflicting rules from akkus.css
   ============================================================ */
@media (min-width: 992px) {
    /* Maximum specificity selectors to ensure sticky positioning */
    html.search-page body .main #content .content.full .container .row aside.sidebar.right-sidebar.col-md-3,
    html.search-page body .main #content .content.full .container .row .sidebar.right-sidebar.col-md-3,
    html.search-page .main #content .content.full .container .row aside.sidebar.right-sidebar.col-md-3,
    html.search-page .main #content .content.full .container .row .sidebar.right-sidebar.col-md-3,
    html.search-page .container .row aside.sidebar.right-sidebar.col-md-3,
    html.search-page .container .row .sidebar.right-sidebar.col-md-3 {
        position: sticky !important;
        top: 67px !important;
        z-index: 100 !important;
        float: none !important;
        clear: none !important;
        align-self: flex-start !important;
        height: max-content !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Ensure parent containers allow sticky - maximum specificity */
    html.search-page body .main,
    html.search-page body #content,
    html.search-page body .content.full,
    html.search-page body .container,
    html.search-page .main,
    html.search-page #content,
    html.search-page .content.full,
    html.search-page .container {
        overflow: visible !important;
        height: auto !important;
        position: relative !important;
    }
    
    /* Ensure row uses flexbox - maximum specificity */
    html.search-page body .main #content .content.full .container .row,
    html.search-page .main #content .content.full .container .row,
    html.search-page .container .row {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: flex-start !important;
        overflow: visible !important;
        position: relative !important;
        height: auto !important;
    }
}
