/* --- 1. RESET & CHUNG (GIỮ NGUYÊN) --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f4f4f4;
}

.container {
    max-width: 1200px;
    margin: auto;
    padding: 0 15px;
}

/* --- 2. HEADER & MENU (GIỮ NGUYÊN + TỐI ƯU) --- */
header {
    background: #fff;
    padding: 15px 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#main-logo {
    height: 50px;
}

nav ul {
    display: flex;
    list-style: none;
}

nav ul li {
    margin-left: 20px;
}

nav a {
    text-decoration: none;
    color: #0056b3;
    font-weight: bold;
    transition: 0.3s;
}

nav a:hover,
nav a.active {
    color: #d9534f;
}

/* --- 3. SECTION & BANNER (GIỮ NGUYÊN) --- */
.banner-img {
    width: 100%;
    display: block;
    object-fit: cover;
}

.section-title {
    text-align: center;
    margin: 40px 0 20px;
    color: #0056b3;
    text-transform: uppercase;
}

.grid-container {
    display: grid;
    gap: 20px;
    margin-bottom: 40px;
}

/* --- 4. PHÂN CHIA CỘT (PC - 1024px trở lên) --- */
@media (min-width: 1024px) {

    /* Trang chủ & Sản phẩm: 4 cột */
    #list-mua-ban,
    #list-san-pham,
    #list-linh-kien-full {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Dự án: 2 cột */
    #list-du-an {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- 5. TABLET (600px - 1023px) --- */
@media (min-width: 600px) and (max-width: 1023px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
/* --- 6. MOBILE (Dưới 600px) --- */
@media (max-width: 599px) {
    .nav-flex { 
        flex-direction: row !important; /* Giữ logo và nút 3 gạch nằm ngang */
        justify-content: space-between;
        padding: 10px 15px;
    }

    #menu-icon {
        display: block !important; /* Hiện nút 3 gạch */
        font-size: 30px;
        cursor: pointer;
        color: #0056b3;
    }

    nav ul {
        display: none; /* Mặc định ẩn menu */
        flex-direction: column;
        width: 100%;
        background: #ffffff;
        position: absolute;
        top: 60px; /* Chỉnh cái này tùy theo độ cao header của bạn */
        left: 0;
        z-index: 1000;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    }

    /* ĐÂY LÀ DÒNG QUAN TRỌNG NHẤT: Khi bấm nút sẽ hiện menu */
    nav ul.show {
        display: flex !important;
    }

    nav ul li {
        margin: 0 !important;
        text-align: center;
        border-bottom: 1px solid #eee;
    }

    nav a {
        display: block;
        padding: 15px;
        width: 100%;
    }
}

/* Ẩn nút 3 gạch trên PC */
@media (min-width: 600px) {
    #menu-icon { display: none; }
    nav ul { display: flex !important; } /* Luôn hiện trên PC */
}

/* --- 7. CARD STYLE (CHUNG CHO TẤT CẢ) --- */
.card {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.card img {
    width: 100%;
    /* Luôn rộng bằng chiều rộng của Card */
    height: 160px;
    /* ĐÂY LÀ CHIỀU CAO CỐ ĐỊNH - Bạn có thể chỉnh thành 180px nếu muốn cao hơn */
    object-fit: contain;
    /* THẦN CHÚ: Giữ tỉ lệ ảnh, không làm méo hình */
    background: #fdfdfd;
    /* Thêm nền xám nhạt để những khoảng trống của ảnh lộn xộn trông chuyên nghiệp hơn */
    padding: 5px;
    /* Tạo khoảng cách nhỏ để ảnh không dính sát viền Card */
    display: block;
}

.card h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #222;
    height: 45px;
    overflow: hidden;
}

.price {
    color: #d9534f;
    font-weight: bold;
    margin-bottom: 5px;
}

.desc {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
    flex-grow: 1;
}

/* --- 8. BỘ LỌC LINH KIỆN (MỚI) --- */
.filter-section {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

#searchInput {
    flex: 3;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    outline: none;
}

#categoryFilter {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* --- 9. NÚT BẤM (ZALO & CONTACT) --- */
.btn-contact,
.btn-zalo {
    display: block;
    text-align: center;
    background: #0068ff;
    color: white;
    text-decoration: none;
    padding: 10px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
    width: 100%;
}

.btn-contact:hover,
.btn-zalo:hover {
    background: #0052cc;
}

/* Nút Back to Top */
#backToTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    z-index: 1000;
}

.badge {
    display: inline-block;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    margin-right: 5px;
    margin-bottom: 5px;
}

.item-lk h3 {
    margin-top: 5px;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.4;
}

/* Màu cho trang đang hiển thị */
#main-menu a.active {
    color: #d9534f !important;
    border-bottom: 2px solid #d9534f;
}