@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;700&display=swap');

/* =========================================
   1. CẤU HÌNH CƠ BẢN & LAYOUT
   ========================================= */
body {
    font-family: 'Be Vietnam Pro', Arial, sans-serif;
    color: #333;
    line-height: 1.6;
    background-color: #f8f9fa;
    margin: 0;
    overflow-x: hidden;
}

main {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

/* Tiện ích chống copy */
.copy-protection-enabled {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.copy-protection-enabled img { pointer-events: none; }

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
.site-header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    height: 70px;
}

.header-logo img {
    max-height: 50px;
    width: auto;
    display: block;
}

/* Menu Desktop */
.header-nav.desktop-nav > ul {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-nav ul li a {
    font-weight: 500;
    padding: 10px;
    transition: color 0.2s;
}
.header-nav ul li a:hover { color: #007bff; }

/* Dropdown Menu (User & Quản lý) */
.dropdown { position: relative; }
.dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0; /* Canh phải cho User menu */
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    border-radius: 6px;
    padding: 8px 0;
    min-width: 200px;
    z-index: 1001;
    border: 1px solid #eee;
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu li a {
    display: block;
    padding: 10px 20px;
    white-space: nowrap;
    color: #333;
}
.dropdown-menu li a:hover { background-color: #f8f9fa; color: #007bff; }

/* Mobile Menu Toggle */
.mobile-menu-toggle { display: none; font-size: 1.5rem; cursor: pointer; background: none; border: none; }

/* =========================================
   3. BANNER SLIDER
   ========================================= */
.banner-slider-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 1500 / 500; /* Tỉ lệ khung hình */
}
.banner-slider-wrapper { display: flex; transition: transform 0.5s ease-in-out; height: 100%; }
.banner-slide { min-width: 100%; height: 100%; }
.banner-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Nút điều hướng Slider */
.slider-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background-color: rgba(0,0,0,0.5); color: white;
    border: none; cursor: pointer; padding: 10px;
    z-index: 10; border-radius: 50%; width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
}
.slider-btn:hover { background-color: rgba(0,0,0,0.8); }
.prev-btn { left: 15px; }
.next-btn { right: 15px; }
.slider-dots {
    position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 8px;
}
.dot {
    cursor: pointer; height: 10px; width: 10px;
    background-color: rgba(255,255,255,0.5); border-radius: 50%;
    transition: background 0.3s;
}
.dot.active { background-color: #fff; }

/* =========================================
   4. CARD TIN ĐĂNG (LISTING CARD)
   ========================================= */
#data-container {
    display: grid;
    /* Thay đổi từ auto-fill minmax sang fix cứng 2 cột */
    grid-template-columns: 1fr 1fr; 
    gap: 25px;
    margin-bottom: 40px;
}

/* Khi ở chế độ tìm kiếm, #data-container chuyển thành block để chứa tiêu đề */
#data-container.search-results-layout {
    display: block; 
}

/* Grid con cho từng khu vực tin (Kết quả tìm kiếm) */
.listing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Ép cứng 2 cột */
    gap: 25px;
    margin-bottom: 40px;
}

/* Grid con cho tin nổi bật */
.listing-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Ép cứng 2 cột */
    gap: 20px;
}


.listing-card {
    background-color: #fff; /* Nên để trắng cho sạch, thay vì lightblue */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    gap: 15px;
    padding: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.listing-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

/* Ảnh Thumbnail */
.listing-card-image-container {
    width: 40%; max-width: 220px; flex-shrink: 0;
    border-radius: 6px; overflow: hidden;
}
.listing-card-image-container img {
    width: 100%; height: 160px; object-fit: cover; display: block;
}

/* Nội dung Card */
.listing-card-info {
    flex-grow: 1;
    display: flex; flex-direction: column; justify-content: space-between;
}
.listing-card-info h4 {
    margin: 0 0 5px; font-size: 1.1em; color: #0056b3;
    line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.listing-card-price strong { color: #d9534f; font-size: 1.1em; }
.listing-card-type, .listing-card-posted-at { font-size: 0.85em; color: #777; margin: 2px 0; }

/* Tin Nổi Bật (Section) */
.featured-results-wrapper {
    background-color: #f0f8ff;
    border: 1px solid #cce5ff;
    border-radius: 8px; padding: 20px; margin-bottom: 30px;
}
.search-section-header h3 { color: #0056b3; margin-top: 0; }
.btn-view-all-tenant {
    background: #fff; color: #007bff; border: 1px solid #007bff;
    padding: 8px 20px; border-radius: 20px; cursor: pointer; font-weight: 600;
}
.btn-view-all-tenant:hover { background: #007bff; color: #fff; }

/* =========================================
   5. BỘ LỌC & MODAL TÌM KIẾM (Đã tối ưu)
   ========================================= */
/* Nút Mở Bộ Lọc */
.filter-trigger-container { text-align: right; margin-bottom: 15px; }
.btn-open-filter {
    background-color: #007bff; color: white; border: none;
    padding: 10px 25px; border-radius: 30px;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,123,255,0.3);
    display: inline-flex; align-items: center; gap: 8px;
    transition: transform 0.2s;
}
.btn-open-filter:hover { transform: translateY(-2px); background-color: #0056b3; }

/* Modal Overlay chung */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 2000; /* Cao nhất */
    justify-content: center; align-items: center;
    padding: 10px;
}

/* Modal Content (Bộ lọc) */
.filter-modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%; max-width: 1000px;
    min-height: 60vh; max-height: 90vh;
    display: flex; flex-direction: column;
    overflow: hidden;
}

.filter-modal-header {
    padding: 15px 20px; border-bottom: 1px solid #eee;
    display: flex; justify-content: space-between; align-items: center;
    background-color: #f8f9fa;
}
.filter-modal-header h2 { margin: 0; font-size: 1.2rem; }
.close-btn { background: none; border: none; font-size: 2rem; cursor: pointer; color: #666; line-height: 1; }

/* Form Bộ Lọc */
.filter-form-reset {
    flex: 1;
    overflow-y: auto; overflow-x: hidden;
    padding: 25px;
}

.filter-grid {
    display: grid;
    /* Tự động chia cột thông minh, tối thiểu 220px */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.filter-group label { font-weight: 600; font-size: 0.9em; display: block; margin-bottom: 5px; }
.filter-control, .multiselect-dropdown .dropdown-toggle {
    width: 100%; height: 42px;
    padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;
    background: #fff; font-size: 0.95em;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; box-sizing: border-box;
}

/* Dropdown Custom (Quận, Phường...) */
.multiselect-dropdown { position: relative; width: 100%; }
.multiselect-dropdown .dropdown-options {
    display: none;
    position: absolute;
    top: 100%; left: 0; width: 100%;
    max-height: 250px; overflow-y: auto;
    background: #fff; border: 1px solid #ced4da;
    border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1050;
    margin-top: 2px;
    padding: 5px 0;
}
.multiselect-dropdown.is-open .dropdown-options { display: block; }

.dropdown-options .checkbox-label {
    display: block; padding: 8px 15px;
    cursor: pointer; font-size: 0.9em;
}
.dropdown-options .checkbox-label:hover { background-color: #f1f3f5; }
.dropdown-options input[type="checkbox"] { margin-right: 10px; }

/* Thanh trượt giá */
.price-range-dropdown { padding: 20px 15px; }
.price-range-slider { position: relative; height: 5px; background: #ddd; margin: 10px 0; border-radius: 5px; }
.price-range-progress { position: absolute; height: 100%; background: #007bff; }
.price-range-slider input[type="range"] {
    position: absolute; top: -5px; width: 100%;
    pointer-events: none; -webkit-appearance: none; background: none;
}
.price-range-slider input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto; width: 18px; height: 18px;
    background: #fff; border: 2px solid #007bff; border-radius: 50%; cursor: pointer;
}
.price-range-inputs { display: flex; justify-content: space-between; gap: 10px; margin-top: 15px; }
.price-input-wrapper { display: flex; align-items: center; gap: 5px; font-size: 0.9em; }
.price-input-wrapper input { width: 60px; padding: 5px; text-align: center; border: 1px solid #ccc; border-radius: 4px; }

/* Nút hành động (Sticky Bottom) */
.sticky-actions {
    position: sticky; bottom: -25px;
    background: #fff; padding: 15px 0;
    border-top: 1px solid #eee;
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 20px; margin-left: -25px; margin-right: -25px; padding-right: 25px; /* Bù padding cha */
}
.sticky-actions button {
    padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-weight: 600;
}
#apply-filters-button { background: #007bff; color: white; }
#reset-filters-button { background: #f8f9fa; color: #333; border: 1px solid #ddd; }

/* =========================================
   6. CHI TIẾT TIN ĐĂNG & CÁC THÀNH PHẦN KHÁC
   ========================================= */
.detail-container {
    max-width: 1200px; /* Giới hạn chiều rộng để dễ đọc */
    margin: 0 auto;
    padding: 30px 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.detail-section { margin-bottom: 30px; }
.detail-section h3 { border-bottom: 2px solid #007bff; padding-bottom: 10px; color: #0056b3; }

/* Gallery Ảnh */
.main-image-wrapper { position: relative; margin-bottom: 10px; }
#main-image { width: 1200px; aspect-ratio: 16/7; object-fit: contain; background: #000; border-radius: 8px; }
.thumbnail-strip { display: flex; gap: 10px; overflow-x: auto; padding: 5px 0; }
.thumbnail-image { width: 80px; height: 60px; object-fit: cover; cursor: pointer; border-radius: 4px; opacity: 0.6; }
.thumbnail-image.active { opacity: 1; border: 2px solid #007bff; }

/* Nút Lưu tin */
.save-button {
    background: #f8f9fa; border: 1px solid #ddd; padding: 8px 15px;
    border-radius: 20px; cursor: pointer; margin-left: 15px;
    display: inline-flex; align-items: center; gap: 5px;
}
.save-button.saved { color: #dc3545; border-color: #dc3545; background: #fff5f5; }
.save-button.saved i { font-weight: 900; }

.listing-header .action-button {
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

/* Nút Sao chép Link */
.copy-link-button:hover {
    background-color: #dde2e6 !important;
    transform: translateY(-2px);
}

.copy-link-button:active {
    transform: translateY(0);
}

/* =========================================
   7. MOBILE MENU (SLIDE OUT)
   ========================================= */
#mobile-menu-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 1001;
    opacity: 0; visibility: hidden; transition: 0.3s;
}
#mobile-menu-overlay.is-open { opacity: 1; visibility: visible; }

#mobile-menu {
    position: fixed; top: 0; left: -280px;
    width: 260px; height: 100%; background: #fff;
    z-index: 1002; transition: left 0.3s; padding: 20px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}
#mobile-menu.is-open { left: 0; }
#mobile-menu ul li a { display: block; padding: 12px 0; border-bottom: 1px solid #eee; }

/* =========================================
   8. RESPONSIVE (MOBILE)
   ========================================= */
@media (max-width: 768px) {
    /* Header */
    .header-container { height: 60px; }
    .header-nav.desktop-nav { display: none !important; }
    .mobile-menu-toggle { display: block; }
    .header-logo { position: absolute; left: 50%; transform: translateX(-50%); }
    #user-actions { display: none; } /* Hoặc hiển thị icon user nhỏ */

    /* Card */
    #data-container, 
    .listing-grid, 
    .listing-preview-grid {
        /* Sử dụng !important để chắc chắn ghi đè cấu hình 2 cột ở trên */
        grid-template-columns: 1fr !important; 
        gap: 15px; /* Giảm khoảng cách giữa các tin cho gọn */
    }

    .listing-card {
        flex-direction: row; /* Vẫn giữ ảnh bên trái, chữ bên phải */
        padding: 10px;
    }
    .listing-card-image-container { width: 120px; height: 120px; }
    .listing-card-info h4 { font-size: 1em; }

    /* Filter Button Sticky */
    .filter-trigger-container {
        position: sticky; top: 70px; z-index: 99;
        background: #f8f9fa; margin: 0 -15px 15px; padding: 10px;
        border-bottom: 1px solid #ddd; text-align: center;
    }
    .btn-open-filter { width: 100%; justify-content: center; }

    /* Modal trên Mobile */
    .filter-modal-content {
        width: 100% !important; height: 100%; max-height: 100%;
        border-radius: 0;
    }
    .filter-grid { grid-template-columns: 1fr; } /* 1 cột cho form */
    
    /* Dropdown trên Mobile (Popup full màn hình dễ bấm) */
    .multiselect-dropdown.is-open .dropdown-options {
        position: none; top: 20%; left: 5%; width: 90%;
        max-height: 60vh; border-radius: 8px;
        box-shadow: 0 0 20px rgba(0,0,0,0.5);
    }
}

.related-listings-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 0; /* Xóa padding để nút sát mép */
}

/* Style chung cho 2 nút (To hơn, nằm giữa, nổi lên trên) */
.related-listings-wrapper .slider-nav {
    position: absolute !important; /* Bắt buộc absolute */
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 100;
    
    width: 40px !important;
    height: 40px !important;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.related-listings-wrapper .slider-nav:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Định vị trái phải */
.related-listings-wrapper .slider-nav.prev { left: 10px !important; }
.related-listings-wrapper .slider-nav.next { right: 10px !important; }


@media (max-width: 768px) {
    .related-listings-wrapper .slider-nav {
        display: flex !important;
        width: 35px !important;
        height: 35px !important;
        font-size: 20px;
    }
    .related-listings-wrapper .slider-nav.prev { left: 5px !important; }
    .related-listings-wrapper .slider-nav.next { right: 5px !important; }
}
