@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;700&display=swap');

body {
    font-family: 'Be Vietnam Pro', Arial, sans-serif; 
    color: #333;
    line-height: 1.6;
    background-color: #f8f9fa;
    margin: 0;
    overflow-x: hidden; /* QUAN TRỌNG: Ngăn cuộn ngang trên mọi màn hình */
}

main {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* ===== 2. HEADER & NAVIGATION ===== */
.site-header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    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;
}

.header-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}

.header-nav ul li {
    position: relative;
    margin-left: 15px;
}

.header-nav ul li a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}

.header-nav ul li a:hover {
    color: #007bff;
}

.site-header .header-container .header-nav.desktop-nav > ul {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
}

.copy-protection-enabled {
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none;     /* IE 10+ */
  -moz-user-select: none;
  user-select: none;         /* Standard syntax */
  -webkit-touch-callout: none;
}

.copy-protection-enabled img {
  pointer-events: none;
}

.banner-container {
    max-width: 1500px;
    aspect-ratio: 1500 / 500; /* << THAY THẾ CHO `height` */
    margin: 20px auto;
    border-radius: 8px;
    overflow: hidden;
    display: block;
}

.banner-container a,
.banner-container img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
}


.save-button.saved i.fas.fa-heart {
color: red;
}

/* Dropdown Menu */
.dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    border-radius: 6px;
    padding: 8px 0;
    list-style: none;
    width: 220px;
    z-index: 1001;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu li {
    margin: 0;
}

.dropdown-menu li a {
    padding: 10px 15px;
    white-space: nowrap;
}

.dropdown-menu li a:hover {
    background-color: #f8f9fa;
}

.home-listing-section {
    margin-bottom: 40px;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.section-title-link {
    text-decoration: none;
    color: #0056b3;
    display: inline-block;
    margin-bottom: 15px;
}

.section-title-link h2 {
    margin: 0;
    transition: color 0.2s ease;
}

.section-title-link:hover h2 {
    color: #007bff;
}

.section-title-link .fa-arrow-right {
    font-size: 0.8em;
    margin-left: 10px;
    transition: transform 0.2s ease;
}

.section-title-link:hover .fa-arrow-right {
    transform: translateX(5px);
}

.listing-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Luôn hiển thị 2 cột */
    gap: 20px;
}


/* Nút hamburger mặc định ẩn trên desktop */
.mobile-menu-toggle { display: none; }


/* ===== 3. BỘ LỌC TÌM KIẾM ===== */
#filter-container {
    padding: 20px;
    margin-bottom: 25px;
    background-color: #F0EAD5;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

#filter-container h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.4em;
    color: #343a40;
}

.filter-actions {
    /* Thêm khoảng cách lớn hơn ở trên để đẩy các nút xuống dưới */
    margin-top: 25px; 
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
    display: flex;
    justify-content: flex-end; /* Đảm bảo các nút luôn ở bên phải */
    gap: 10px;
}


/* Dùng CSS Grid để tạo layout 2 hàng */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 0.85em;
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

/* Style chung để các ô lọc có chiều cao bằng nhau */
.filter-control {
    height: 40px;
    padding: 8px 12px;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 0.9em;
    font-family: inherit; /* Thừa hưởng font từ body */
    width: 100%;
    box-sizing: border-box;
    text-align: left;
}
.multiselect-dropdown .dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.dropdown-toggle .dropdown-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dropdown đa lựa chọn */
.multiselect-dropdown { position: relative; }

.multiselect-dropdown .dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    border: 1px solid #ced4da;
    border-radius: 4px;
    margin-top: 2px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 1010;
    padding: 5px;
}
.multiselect-dropdown.is-open .dropdown-options { display: block; }
.dropdown-options .checkbox-label {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9em;
}
.dropdown-options .checkbox-label:hover { background-color: #f0f0f0; }
.dropdown-options .checkbox-label input { margin-right: 8px; }

/* Thanh trượt giá */
.price-range-dropdown { padding: 20px 15px 15px 15px; }
.price-range-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.price-range-values { font-weight: bold; color: #0056b3; }
.price-range-slider { position: relative; height: 5px; background-color: #ddd; border-radius: 5px; }
.price-range-slider .price-range-progress { position: absolute; height: 100%; background-color: #007bff; border-radius: 5px; }
.price-range-slider input[type="range"] { position: absolute; top: -5px; width: 100%; -webkit-appearance: none; background: transparent; pointer-events: none; }
.price-range-slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; background: #fff; border: 2px solid #007bff; border-radius: 50%; cursor: pointer; }
.price-range-slider input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; background: #fff; border: 2px solid #007bff; border-radius: 50%; cursor: pointer; }
.price-range-inputs { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.price-input-wrapper { display: flex; align-items: center; gap: 5px; }
.price-range-inputs input[type="number"] { width: 70px; padding: 5px; border: 1px solid #ccc; border-radius: 4px; text-align: center; }
.price-range-inputs input::-webkit-outer-spin-button, .price-range-inputs input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }


/* ===== 4. CARD TIN ĐĂNG ===== */
#data-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); /* Responsive */
    gap: 25px;
}

.listing-card {
    background-color: #F0EAD5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding: 15px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.listing-card:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    transform: translateY(-5px);
}

.listing-card-image-container {
    flex-shrink: 0;
    width: 40%;
    max-width: 220px;
    background-color: #f5f5f5;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.listing-card-image-container img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.listing-card-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.listing-card-info h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #1a0dab;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listing-card-info p {
    margin: 4px 0;
    font-size: 0.9em;
    color: #4d5156;
}

.listing-card-price strong {
    font-size: 1.1em;
    font-weight: 700;
    color: #d9534f;
}

.listing-card-type, .listing-card-posted-at {
    font-style: italic;
    color: #777;
}

.site-footer {
    position: relative; /* Làm gốc để định vị lớp nền ảo ::before */
    color: black; /* Màu chữ trắng trên nền tối */
    overflow: hidden; /* Ngăn các thành phần con tràn ra ngoài */
    
    /* YÊU CẦU 7: Màu nền cho phần chữ tràn xuống, giống màu nền chung của trang */
    background-color: #F0EAD5; 
}

/* Lớp nền ảo ::before chứa ảnh nền và lớp phủ mờ */
.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 500px; /* Chiều cao của khu vực ảnh nền, bạn có thể thay đổi */
    z-index: 0; /* Nằm dưới nội dung chữ */

    /* YÊU CẦU 1: Ảnh nền và lớp phủ mờ */
    background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0)), url('https://storage.googleapis.com/khonhachinhchu1-images/listings-images/z6717731297253_8089628f8352859737d2cc1a3e41f234.jpg');
    
    /* YÊU CẦU 6: Hiển thị đầy đủ ảnh, không cắt xén */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center top; /* Canh ảnh ở trên cùng, chính giữa */
}

/* Khối chứa nội dung 4 cột */
.footer-content-container {
    position: relative; /* Để nằm trên lớp nền ảo ::before */
    z-index: 1;

    /* Canh giữa layout */
    max-width: 1200px;
    margin: 0 auto;

    /* YÊU CẦU 4: Đẩy nội dung xuống nửa dưới của ảnh */
    padding-top: 250px;  /* Khoảng 1/2 chiều cao của lớp ::before */
    padding-bottom: 50px;/* Khoảng đệm dưới cùng */
    padding-left: 20px;
    padding-right: 20px;

    /* YÊU CẦU 2: Chia thành 4 cột bằng nhau */
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

/* YÊU CẦU 5: Định dạng chung cho tiêu đề H4 */
.footer-column h4 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #777;
    font-size: 1.2em;
}

/* YÊU CẦU 3: Canh lề cho các cột */
.footer-column:nth-child(1), /* Cột 1 (bên trái) */
.footer-column:nth-child(4) { /* Cột 4 (bên phải) */
    text-align: left;
}

.footer-column:nth-child(2), /* Cột 2 (giữa) */
.footer-column:nth-child(3) { /* Cột 3 (giữa) */
    text-align: center;
}

/* Định dạng chung khác */
.footer-column p,
.footer-column ul li {
    font-size: 0.9em;
    color: black;
    line-height: 1.7;
}
.footer-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-column ul li {
    margin-bottom: 10px;
}
.footer-column a {
    color: black;
    text-decoration: none;
}
.footer-column a:hover {
    color: #fff;
}

#pagination-container {
    text-align: center;
    margin: 40px 0; /* Tăng khoảng cách trên và dưới */
}


#mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

/* Kích hoạt lớp phủ mờ khi menu mở */
#mobile-menu-overlay.is-open {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

/* Khung menu chính, mặc định ẩn bên trái */
#mobile-menu {
    position: fixed;
    top: 0;
    left: -280px; /* QUAN TRỌNG: Ẩn panel về phía bên trái */
    width: 250px;
    height: 100%;
    background-color: #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    z-index: 1002;
    transition: left 0.3s ease-in-out;
    padding: 20px;
    box-sizing: border-box;
    display: block; /* Đảm bảo nó luôn được render để JS có thể tìm thấy */
}

/* Khi có class 'is-open', trượt panel vào trong màn hình */
#mobile-menu.is-open {
    left: 0;
}

/* Nút đóng menu mobile */
#mobile-menu-close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2em;
    color: #333;
    background: none;
    border: none;
    cursor: pointer;
}

/* Danh sách link trong menu mobile */
#mobile-menu ul {
    list-style: none;
    padding: 0;
    margin-top: 50px;
}

#mobile-menu ul li {
    margin: 0;
}

#mobile-menu ul li a {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: #333;
    font-weight: 500;
}

/* ===== 5. RESPONSIVE CHO DI ĐỘNG ===== */
@media (max-width: 768px) {

    /* --- Bố cục chung --- */
    body {
        overflow-x: hidden;
    }

    main, .site-header {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* --- Header & Menu --- */
    .header-container {
        display: flex;
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center;
        height: 60px;
    }

    .header-nav.desktop-nav {
        display: none !important;
    }
    
    .listing-preview-grid {
        grid-template-columns: 1fr; /* Chuyển thành 1 cột trên di động */
    }

    .mobile-menu-toggle { display: block; }
    
    .header-logo { position: absolute; left: 50%; transform: translateX(-50%); }
    .mobile-menu-toggle, #user-actions { flex: 1; }
    #user-actions { display: flex; justify-content: flex-end; }
    #user-display-name, #user-menu-trigger .fa-angle-down { display: none; }
    #user-menu-trigger::before {
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        content: "\f007";
        font-size: 1.3em;
        padding: 10px;
    }
    
    /* --- CARD TIN ĐĂNG --- */
    #data-container {
        grid-template-columns: 1fr;
    }

    .listing-card {
        flex-direction: row; /* <<== QUAN TRỌNG: Giữ lại layout 2 cột */
        gap: 12px;
        padding: 12px;
    }

    .listing-card-image-container {
        width: 100px;  /* Thu nhỏ cột ảnh */
        height: 100px;
        flex-shrink: 0;
        max-width: none;
    }

    .listing-card-image-container img {
        object-fit: cover;
    }

    .listing-card-info h4 {
        font-size: 0.9em;
        line-height: 1.3;
        margin-bottom: 5px;
    }

    .listing-card-info p {
        font-size: 0.8em;
        margin: 2px 0;
    }

    .listing-card-price strong {
        font-size: 1em;
    }


    /* --- Bộ lọc --- */
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .multiselect-dropdown.is-open .dropdown-options {
        position: fixed;
        top: 15%; left: 5%;
        width: 90%;
        max-height: 70vh;
    }

    .multiselect-dropdown.is-open .dropdown-apply-btn {
        display: block; /* Hiện nút ra khi dropdown được mở */
        width: 100%;
        padding: 12px;
        margin-top: 10px; /* Khoảng cách với phần nội dung bên trên */
        border: none;
        border-top: 1px solid #eee; /* Đường kẻ phân cách */
        background-color: #007bff;
        color: white;
        font-size: 1em;
        font-weight: bold;
        cursor: pointer;
        
        /* Đảm bảo nút dính ở dưới cùng của dropdown */
        position: sticky;
        bottom: 0;
    }

    .multiselect-dropdown.is-open .dropdown-apply-btn:hover {
        background-color: #0056b3;
    }

    /* ========================================================= */
    /* === CSS CHO FOOTER TRÊN DI ĐỘNG (ĐÃ SỬA LỖI HOÀN CHỈNH) === */
    /* ========================================================= */
    .site-footer::before {
        height: 300px; /* Giảm chiều cao ảnh nền trên di động */
    }
    .footer-content-container {
        padding-top: 150px;
        
        /* SỬA LỖI 3: Chuyển thành lưới 2x2 trên di động */
        grid-template-columns: 1fr 1fr; 
    }
    
    /* Canh lề trái cho tất cả các cột trên di động cho thống nhất */
    .footer-column:nth-child(1),
    .footer-column:nth-child(2),
    .footer-column:nth-child(3),
    .footer-column:nth-child(4) {
        text-align: left;
    }
    .footer-column h4 {
        display: block; /* Cho tiêu đề chiếm hết chiều rộng cột trên mobile */
    }
}