/* Listing Cards & Grids */
.main-wrapper {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    padding-top: 20px;
}

.sidebar {
    background: var(--white);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    height: fit-content;
}

.sidebar h3 {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 4px;
}

.filter-group { margin-bottom: 20px; }
.filter-group ul { list-style: none; }
.filter-group li { font-size: 0.85rem; padding: 4px 0; }
.filter-group a { color: #444; text-decoration: none; transition: all 0.2s; display: block; }
.filter-group a:hover, .filter-group a.active { color: var(--primary-color); font-weight: 700; padding-left: 5px; }
.filter-group a.active { border-left: 3px solid var(--accent-color); }

/* Search Bar Fix */
.search-section { background: #f8f9fa; padding: 20px 0; border-bottom: 1px solid #eee; margin-bottom: 20px; }
.search-bar { background: #fff; padding: 8px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); border: 1px solid #eee; overflow: hidden; }
.search-bar form { display: flex; gap: 10px; width: 100%; }
.search-bar select, .search-bar input { padding: 12px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 0.95rem; outline: none; flex: 1; }
.search-bar input[name="keyword"] { flex: 2; }
.search-bar select:focus, .search-bar input:focus { border-color: var(--primary-color); }
.btn-search { background: var(--primary-color); color: #fff; border: none; padding: 0 30px; border-radius: 6px; cursor: pointer; font-weight: 700; transition: background 0.3s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-search:hover { background: #003366; }

/* Showcase Section */
.showcase-section {
    margin-bottom: 30px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.showcase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.showcase-header h2 { font-size: 1rem; color: var(--primary-color); font-weight: 700; }

.showcase-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.showcase-card { text-decoration: none; color: inherit; transition: transform 0.2s; }
.showcase-card:hover { transform: translateY(-3px); }
.showcase-img {
    width: 100%;
    height: 100px;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    margin-bottom: 6px;
    border: 1px solid #eee;
}

.showcase-card-title {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    height: 2.4em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 4px;
}

.showcase-card-price { font-size: 0.85rem; font-weight: 800; color: var(--primary-color); }

/* List View */
.listings-container {
    background: var(--white);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.listing-item-wrapper {
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.listing-item-wrapper:last-child {
    border-bottom: none;
}

.listing-item {
    display: flex;
    padding: 8px 12px;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
    align-items: center;
    gap: 12px;
}

.listing-item:hover { background: #f9f9f9; }

.fav-btn {
    transition: transform 0.2s;
    padding: 12px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fav-btn:hover {
    transform: scale(1.15);
}
.listing-thumb {
    width: 80px;
    height: 60px;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid #eee;
}

.listing-details {
    flex: 1;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
}

.listing-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

.listing-meta { font-size: 0.75rem; color: #4b5563; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-price { font-size: 1rem; font-weight: 800; color: #002f5f; text-align: right; min-width: 100px; margin-left: 10px; }

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.pagination a, .pagination strong {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    color: #1e293b;
    font-weight: 600;
    background: #fff;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pagination a.active, .pagination strong {
    background: #002f5f;
    color: #fff;
    border-color: #002f5f;
}

.pagination a:hover:not(.active) {
    background: #f1f5f9;
}

/* Detail Page */
.left-col, .right-col { min-width: 0; width: 100%; }
.listing-header-section { background: #fff; padding: 20px 0; border-bottom: 1px solid #eee; margin-bottom: 20px; }
.listing-container { display: grid; grid-template-columns: 2fr 1fr; gap: 30px; min-width: 0; }
.info-box { background: #fff; padding: 20px; border-radius: 8px; border: 1px solid #ddd; margin-bottom: 20px; word-wrap: break-word; overflow: hidden; }
.price-tag { font-size: 2rem; font-weight: 800; color: var(--primary-color); margin-bottom: 15px; }

/* Gallery System */
.gallery-container {
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #eee;
    margin-bottom: 25px;
    overflow: hidden;
    width: 100%;
}

.main-image-wrapper {
    width: 100%;
    height: 500px;
    background-color: #f8f8f8;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
    cursor: zoom-in;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.3s;
    z-index: 10;
}

.gallery-nav:hover { background: rgba(0,0,0,0.8); }
.gallery-nav.prev { left: 15px; }
.gallery-nav.next { right: 15px; }

.thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.thumb {
    width: 90px;
    height: 65px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    object-fit: cover;
    flex-shrink: 0;
    opacity: 0.7;
    transition: all 0.2s;
}

.thumb:hover, .thumb.active {
    opacity: 1;
    border-color: var(--primary-color);
}

/* Fullscreen Overlay Improved */
#fullscreenOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

#fullscreenImage {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.fs-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    opacity: 0.7;
}

.fs-close:hover { opacity: 1; }

/* Spec Table Optimized */
.spec-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-bottom: 0;
    background: #fff;
    overflow: hidden;
}

.spec-table tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.spec-table tr:hover {
    background: #f8fafc;
}

.spec-table tr:last-child {
    border-bottom: none;
}

.spec-table td {
    padding: 7px 12px;
    line-height: 1.4;
}

.spec-table td:first-child {
    font-weight: 600;
    color: #64748b;
    width: 45%;
}

.spec-table td:last-child {
    color: #0f172a;
    font-weight: 700;
    text-align: right;
}

.realtor-box {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    text-align: center;
    position: sticky;
    top: 90px;
}

.realtor-box h3 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.realtor-name-sub {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
    display: block;
}

.realtor-phone {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-color);
    padding: 10px;
    background: #f0f7ff;
    border-radius: 4px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Profile Page */
.profile-header {
    background: var(--primary-color);
    color: #fff;
    padding: 40px 0;
    margin-bottom: 30px;
}

.profile-info-grid {
    display: flex;
    align-items: center;
    gap: 30px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background: var(--accent-color);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
}

/* Mobile & Tablet */
@media (max-width: 992px) {
    .main-wrapper { grid-template-columns: 1fr; }
    .listing-container { grid-template-columns: 1fr; }
    
    .sidebar { 
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 2000;
        background: #fff;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 15px rgba(0,0,0,0.2);
    }
    
    .sidebar.open { left: 0; }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1999;
    }
    
    .sidebar-overlay.active { display: block; }
    
    .search-bar form { flex-direction: column; gap: 5px; }
    .search-bar select, .search-bar input, .btn-search { width: 100% !important; height: 45px; margin: 0; }
    
    .sidebar-header { display: flex !important; }
    .desktop-only { display: none !important; }
    .mobile-action-bar { display: flex !important; }
    
    .search-sidebar {
        display: block !important;
        position: fixed;
        left: -320px;
        top: 0;
        bottom: 0;
        width: 300px;
        z-index: 2001;
        background: #fff;
        transition: left 0.3s ease;
        padding: 20px;
        overflow-y: auto;
        box-shadow: 2px 0 15px rgba(0,0,0,0.2);
    }
    .search-sidebar.open { left: 0; }
    
    .form-control {
        width: 100%;
        padding: 12px;
        border: 1px solid #ddd;
        border-radius: 8px;
        font-size: 0.95rem;
    }
}

/* Ensure Search Sidebar is hidden on desktop */
@media (min-width: 993px) {
    .search-sidebar { display: none !important; }
}

@media (max-width: 768px) {
    .main-image-wrapper { height: 300px; }
    .container { padding: 0 10px; width: 100%; max-width: 100%; overflow-x: hidden; }
    .main-wrapper { padding-left: 0; padding-right: 0; width: 100%; overflow-x: hidden; }
    .search-section { padding: 15px 0; }
    .search-bar { padding: 5px; margin: 0 5px; }
    
    .listing-item { flex-direction: row !important; padding: 10px !important; align-items: flex-start !important; width: 100%; position: relative; }
    .listing-thumb { width: 90px !important; height: 65px !important; }
    .listing-details { flex-direction: column !important; align-items: flex-start !important; gap: 4px !important; padding-top: 2px; padding-right: 35px; }
    .listing-title { font-size: 0.85rem !important; -webkit-line-clamp: 2 !important; white-space: normal !important; padding-right: 10px; }
    .listing-meta { font-size: 0.75rem !important; }
    .listing-price { font-size: 0.9rem !important; margin: 0 !important; text-align: left !important; min-width: auto !important; }
    .fav-btn { top: 0 !important; right: 0 !important; padding: 8px !important; min-width: 40px !important; min-height: 40px !important; }
    .fav-btn i { font-size: 1.1rem !important; }
    
    .pagination a { padding: 6px 12px; font-size: 0.8rem; }
    
    .features-section .feature-group-wrapper > div {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
    }
}

@media (max-width: 480px) {
    .main-image-wrapper { height: 220px; }
    .thumb { width: 70px; height: 50px; }
}

/* 
   Listing Detail Page Styles
   -------------------------- */

.listing-header-section { background: #fff; border-bottom: 1px solid #eee; padding: 20px 0; margin-bottom: 25px; }
.listing-header-section h1 { font-size: 1.5rem; margin: 0; color: var(--primary-color); }
.listing-header-meta { color: #666; margin-top: 5px; font-size: 0.9rem; }

.listing-container { display: grid; grid-template-columns: 1fr 300px; gap: 30px; margin-bottom: 50px; }
.left-col { min-width: 0; }
.right-col { position: relative; }

/* Gallery */
.gallery-container { margin-bottom: 30px; }
.main-image-wrapper { position: relative; height: 500px; background: #000; border-radius: 12px; overflow: hidden; margin-bottom: 15px; }
.main-image-wrapper img { width: 100%; height: 100%; object-fit: contain; cursor: pointer; }
.thumbnails { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.thumb { width: 80px; height: 60px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; flex-shrink: 0; }
.thumb.active { border-color: var(--accent-color); opacity: 0.7; }

/* Info Boxes & Accordion */
.info-box { background: #fff; border: 1px solid #eee; border-radius: 12px; padding: 20px; margin-bottom: 25px; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }

@media (max-width: 768px) {
    .info-box { padding: 15px; }
}
.accordion-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.accordion-header h2 { margin: 0; font-size: 1.2rem; color: var(--primary-color); }
.accordion-header i { transition: transform 0.3s; color: #999; }
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.accordion-box.active .accordion-content { max-height: 3000px; transition: max-height 0.5s ease-in; }
.accordion-box.active .accordion-header i { transform: rotate(180deg); }

/* Specs Table (Consolidated) */
.spec-table td { padding: 7px 10px; font-size: 0.82rem; }

/* Social Share */
.social-share-bar { display: flex; gap: 10px; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #f0f0f0; }
.share-label { font-size: 0.85rem; font-weight: 700; color: #666; display: flex; align-items: center; }
.share-btn { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; text-decoration: none; color: #fff; font-size: 0.9rem; transition: transform 0.2s, opacity 0.2s; }
.share-btn:hover { transform: translateY(-2px); opacity: 0.9; }
.share-btn.fb { background: #1877F2; }
.share-btn.x { background: #000000; }
.share-btn.pin { background: #E60023; }
.share-btn.wa { background: #25D366; }

/* Realtor Box */
.realtor-box { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid #eee; }
.realtor-main-info { display: flex; align-items: center; gap: 15px; margin-bottom: 20px; }
.realtor-avatar { width: 65px; height: 65px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent-color); }
.realtor-text h3 { margin: 0; font-size: 1.1rem; color: #1a202c; }
.realtor-name-sub { font-size: 0.8rem; color: #718096; }
.realtor-contact-actions { display: flex; flex-direction: column; gap: 10px; }
.action-btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border-radius: 10px; text-decoration: none; font-weight: 700; transition: all 0.2s; font-size: 0.95rem; }
.call-btn { background: #3b82f6; color: #fff; }
.whatsapp-btn { background: #25d366; color: #fff; }
.store-btn { background: #f1f5f9; color: #475569; }
.action-btn:hover { filter: brightness(0.9); transform: translateY(-2px); }

/* Stats & Price */
.price-tag { color: #c53030; font-weight: 800; font-size: 1.8rem; margin-bottom: 10px; }
.listing-stats { display: flex; gap: 15px; font-size: 0.8rem; color: #718096; margin-bottom: 15px; }

/* Similar Listings */
.similar-card-mini { display: flex; gap: 12px; text-decoration: none; color: inherit; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #eee; transition: transform 0.2s, box-shadow 0.2s; }
.similar-card-mini:hover { transform: translateX(5px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.sim-img { width: 80px; height: 80px; background-size: cover; background-position: center; flex-shrink: 0; }
.sim-info { padding: 8px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.sim-title { font-size: 0.85rem; font-weight: 600; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.sim-price { font-size: 0.95rem; font-weight: 700; color: #c53030; margin-bottom: 2px; }
.sim-loc { font-size: 0.75rem; color: #888; }

.mobile-only-similar, .mobile-only-specs { display: none; }
.desktop-only-similar, .desktop-only-specs { display: block; }

@media (max-width: 992px) {
    .listing-container { grid-template-columns: 1fr; gap: 20px; }
    .main-image-wrapper { height: 300px; }
    .mobile-only-similar, .mobile-only-specs { display: block; }
    .desktop-only-similar, .desktop-only-specs { display: none; }
    
    .realtor-box {
        position: fixed !important; bottom: 15px !important; top: auto !important; left: 10px !important; right: 10px !important; z-index: 9999 !important;
        height: 75px !important; padding: 0 12px !important; border-radius: 16px !important; box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
        display: flex !important; align-items: center !important; justify-content: space-between !important; gap: 8px !important; border: none !important; margin: 0 !important;
        background: #fff !important;
    }
    body.has-cookie-bar .realtor-box { bottom: 95px !important; }
    .realtor-main-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
    .realtor-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
    .realtor-text { flex: 1; min-width: 0; overflow: hidden; }
    .realtor-text h3 { font-size: 0.85rem !important; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .realtor-name-sub { font-size: 0.75rem !important; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
    
    .realtor-contact-actions { display: flex; flex-direction: row; gap: 8px; flex-shrink: 0; }
    .action-btn { width: 40px; height: 40px; padding: 0; border-radius: 10px; font-size: 1.1rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
    .action-btn span, .store-btn { display: none; }
    
    .action-btn.revealed { width: auto !important; padding: 0 12px !important; }
    .action-btn.revealed span { display: inline-block !important; font-size: 0.85rem; margin-left: 5px; }
    
    footer { padding-bottom: 100px !important; }
}
