/* =====================================
   Base Styles & Utilities
   ===================================== */
body {
    background-color: #f4f4f4; /* Nền nhẹ nhàng hơn */
    font-family: 'Roboto', sans-serif;
    color: #333;
    line-height: 1.6;
    margin: 0;
    /* Thêm padding dưới để giỏ hàng sticky không che mất nội dung cuối trang */
    padding-bottom: 120px; /* Điều chỉnh nếu giỏ hàng lớn hơn */
}

a {
    color: #e44d26; /* Màu cam đặc trưng */
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #c0392b; /* Màu cam đậm hơn khi hover */
}

h1, h2, h3, h4, h5, h6 {
    color: #333;
    margin-top: 0;
    margin-bottom: 10px;
    font-weight: 700; /* Đảm bảo tiêu đề nổi bật */
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

button {
    cursor: pointer;
    border: none;
    background-color: transparent; /* Mặc định nút không có nền */
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* === Helper Classes === */
.pb-2 { padding-top: .5rem !important; }
.text-danger { color: #dc3545 !important; }
.fw-semibold { font-weight: 600 !important; }
.text-dark { color: #343a40 !important; }

/* =====================================
   Flash Messages (Bootstrap-like)
   ===================================== */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.alert.fade.show {
    opacity: 1;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-dismissible .btn-close {
    padding: 0.5em 0.5em;
    font-size: 1.25em;
    line-height: 1;
    color: #000;
    text-shadow: none;
    opacity: 0.5;
    background-color: transparent;
    border: 0;
    -webkit-appearance: none;
    float: right;
    font-weight: bold;
    margin-top: -0.25em;
    margin-right: -0.25em;
    box-sizing: content-box;
    cursor: pointer;
}

.alert-dismissible .btn-close:hover {
    opacity: 0.75;
}

/* =====================================
   Header & Navigation
   ===================================== */
.site-header {
    padding: 0.75rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-bottom: 1px solid #eee;
    background-color: #fff; /* Đảm bảo nền trắng */
}

.header-logo img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 60px; /* Giới hạn chiều cao logo */
}

/* Header Actions (Login/Account Buttons) */
.header-actions .btn, .btn-login, .btn-account {
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    transition: all 0.2s ease-in-out;
    text-align: center;
    display: inline-block;
    vertical-align: middle;
}

.btn-login, .header-actions .btn-login {
    background-color: #e63900;
    border: 2px solid #e63900;
    color: #fff !important; /* Quan trọng để override Bootstrap */
}

.btn-login:hover, .header-actions .btn-login:hover {
    background-color: #c03000;
    border-color: #c03000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-account, .header-actions .btn-account {
    background-color: #f0f0f0; /* Nền xám nhạt */
    border: 2px solid #ddd;
    color: #333; /* Màu chữ mặc định */
}

.btn-account:hover, .header-actions .btn-account:hover {
    background-color: #e63900; /* Đổi màu nền khi hover */
    border-color: #e63900;
    color: #fff !important; /* Đổi màu chữ khi hover */
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
/* Style cho khối tiêu đề danh mục trên homepage */
.category-title-block {
    text-align: center;
    margin: 40px auto 30px auto; /* Khoảng cách trên dưới, căn giữa */
    background-color: #fff; /* Nền trắng */
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08); /* Bóng nhẹ */
    width: 100%; /* Chiều rộng tối đa */
    display: inline-block; /* Để khối ôm theo nội dung */
    vertical-align: top; /* Tránh vấn đề khoảng trắng */
}

.category-title-block h4 {
    font-size: 1.8rem; /* Kích thước chữ lớn */
    font-weight: bold;
    color: #333; /* Màu chữ đậm */
    margin: 0; /* Bỏ margin mặc định của h4 */
}
/* === Mega Menu === */
.nav-item.dropdown {
    position: static; /* Cho phép dropdown mở rộng ra khỏi nav-item */
}

.dropdown-menu {
    border: none;
    box-shadow: 0 0.25rem 1rem rgba(0,0,0,0.15);
    border-radius: 0.25rem;
    padding: 0.5rem 0;
    min-width: 250px;
    display: none; /* Mặc định ẩn, sẽ hiển thị bằng JS/hover */
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background-color: #fff;
    /* Transition cho hiệu ứng mượt mà khi hiện/ẩn */
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none; /* Không tương tác khi ẩn */
}

.nav-item.dropdown:hover > .dropdown-menu {
    display: block; /* Hiển thị khi hover */
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* Cho phép tương tác */
}


.dropdown-menu .dropdown-item {
    padding: 0.5rem 1rem;
    color: #333;
    font-weight: 500;
    font-size: 15px;
    text-transform: uppercase;
    line-height: 30px;
    white-space: nowrap; /* Ngăn không cho chữ xuống dòng */
}
.dropdown-menu .dropdown-item:hover {
    background-color: #f5f5f5;
    color: #ff4d00;
}

.dropdown-submenu {
    position: relative;
}

.dropdown-submenu > .submenu {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 0.1rem;
    display: none; /* Mặc định ẩn */
    min-width: 200px;
    background-color: #fff;
    border-radius: 0.25rem;
    box-shadow: 0 0.25rem 1rem rgba(0,0,0,0.15);
    padding: 0.5rem 0;
    z-index: 1001;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.dropdown-submenu:hover > .submenu {
    display: block; /* Hiện submenu khi hover */
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}


/* Mega menu grid layout */
.mega-menu-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 2rem;
    padding: 1rem 1.5rem; /* Đảm bảo padding bên trong mega menu */
}
.mega-menu-content .dropdown-header {
    font-weight: bold;
    color: #333;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #eee; /* Thêm đường kẻ dưới tiêu đề */
    padding-bottom: 0.5rem;
}
.mega-menu-content .dropdown-submenu {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
.mega-menu-content .dropdown-submenu li {
    margin-bottom: 0.5rem;
}
.mega-menu-content .dropdown-item {
    padding: 0.35rem 0;
    color: #555;
    font-weight: 500;
    background: transparent !important;
    display: block;
    transition: all 0.2s ease-in-out;
}
.mega-menu-content .dropdown-item:hover {
    color: #ff4d00;
    padding-left: 5px; /* Hiệu ứng trượt nhẹ */
}

/* =====================================
   Mobile Menu (Offcanvas)
   ===================================== */
.mobile-menu .btn {
    background: transparent;
    border: none;
    padding: 0.75rem 0;
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 1px solid rgba(0,0,0,0.1); /* Màu border cho mobile */
    width: 100%; /* Đảm bảo nút chiếm toàn bộ chiều rộng */
    text-align: left;
    color: #333; /* Màu chữ cho mobile menu */
}
.mobile-menu a {
    font-weight: 500;
    text-decoration: none;
    color: #333; /* Màu chữ cho link trong mobile menu */
}
.mobile-menu .submenu a {
    font-size: 16px;
    line-height: 30px;
    padding-left: 1rem; /* Thụt lề cho submenu */
}
.mobile-menu .submenu {
    transition: all 0.3s ease;
    overflow: hidden; /* Quan trọng để ẩn/hiện mượt mà */
    max-height: 0; /* Mặc định ẩn */
}
.mobile-menu-item.open .submenu {
    max-height: 500px; /* Chiều cao lớn hơn để hiển thị nội dung */
}

.mobile-menu .toggle-submenu {
    all: unset; /* Reset tất cả các style mặc định của button */
    display: flex;
    justify-content: space-between;
    align-items: center; /* Căn giữa icon và text */
    width: 100%;
    padding: 0.75rem 0;
    font-size: 18px;
    font-weight: 500;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    cursor: pointer;
    color: #333;
}

.mobile-menu-item i.fa-chevron-right,
.mobile-menu-item i.fa-chevron-down {
    transition: transform 0.3s ease;
}
.mobile-menu-item.open i.fa-chevron-right {
    transform: rotate(90deg);
}

/* Offcanvas Responsive */
@media (max-width: 991.98px) {
    .offcanvas-body ul li a {
        color: #333;
        text-decoration: none;
        padding: 0.5rem 0;
        font-size: 18px;
        font-weight: 500;
    }
    .offcanvas-body ul ul {
        padding-left: 1rem;
    }
    .offcanvas-start {
        max-width: 100vw;
        width: 100%;
        overflow-x: hidden; /* Ngăn chặn cuộn ngang không mong muốn */
    }
    .offcanvas .offcanvas-body {
        overflow-x: hidden;
        padding: 1rem; /* Thêm padding cho body offcanvas */
    }
    .offcanvas .mobile-menu {
        padding-left: 0;
        margin: 0;
    }
    /* Đảm bảo menu chính biến mất trên mobile */
    .navbar-collapse {
        display: none !important;
    }
}

/* =====================================
   Masonry Grid for Downloads
   ===================================== */
.masonry-grid {
    margin-left: -7.5px; /* Bù lại gutter */
    margin-right: -7.5px; /* Bù lại gutter */
}
.masonry-grid:after {
    content: '';
    display: block;
    clear: both;
}
.grid-item {
    /* Đảm bảo tính toán chính xác để tránh lỗi layout */
    width: calc((100% - 5 * 15px) / 6); /* 6 cột với 5 khoảng gutter */
    margin-bottom: 15px;
    float: left;
    padding-left: 7.5px; /* Một nửa gutter */
    padding-right: 7.5px; /* Một nửa gutter */
    box-sizing: border-box; /* Bao gồm padding và border vào width */
}
.photo-item {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}
.photo-item:hover {
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}
.photo-item__link {
    display: block;
}
.photo-item__image {
    width: 100%;
    height: auto;
    display: block;
    padding: 10px;
    border-radius: 8px; /* Bo tròn ảnh bên trong card */
}
.photo-item__caption {
    padding: 12px;
    text-align: center;
}
.photo-item__title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
}
.photo-item__title a {
    text-decoration: none;
    color: #333;
    transition: color 0.3s ease;
}
.photo-item__title a:hover {
    color: #e63900;
}
.photo-item__meta {
    font-size: 0.875rem;
    color: #666;
}

/* =====================================
   Featured Post Grid
   ===================================== */
.custom-post-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6 cột trên desktop */
    gap: 10px;
    width: 100%; /* Thay vì 100vw, sử dụng 100% trong container */
    padding: 0; /* Bỏ padding ngang nếu đã có container */
    margin-left: 0; /* Bỏ margin-left nếu không dùng 100vw */
    box-sizing: border-box;
}
.custom-post-card {
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
    height: 100%; /* Đảm bảo các card cùng chiều cao */
}
.custom-post-card:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.custom-post-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}
.custom-post-thumb-wrapper {
    width: 100%;
    aspect-ratio: 1/1; /* Giữ tỷ lệ 1:1 cho ảnh */
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 12px;
}
.custom-post-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
    transition: transform 0.3s ease;
}
.custom-post-card:hover .custom-post-thumb {
    transform: scale(1.05);
}
.custom-post-title {
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    color: #222;
    background: #fff;
    margin: 0;
    line-height: 1.4;
    flex-grow: 1; /* Đảm bảo tiêu đề chiếm hết không gian còn lại */
    display: flex;
    align-items: center; /* Căn giữa theo chiều dọc nếu có nhiều dòng */
    justify-content: center;
}

.badge.bg-secondary {
    background-color: #6c757d !important; /* Đảm bảo override Bootstrap */
    font-size: 0.75rem;
    padding: 0.25em 0.5em;
    border-radius: 4px;
    display: inline-block; /* Để badge không bị vỡ dòng */
    margin-top: 5px; /* Khoảng cách với nội dung trên */
}


/* =====================================
   Post Content & General Pages
   ===================================== */
.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
    border-radius: 8px; /* Bo tròn ảnh trong nội dung bài viết */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.breadcrumb {
    padding-top: 15px !important; /* Điều chỉnh padding */
    padding-bottom: 15px !important; /* Điều chỉnh padding */
    background: #fff;
    box-shadow: var(--bs-box-shadow-sm, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075)) !important;
    border-radius: 10px;
    margin-bottom: 20px; /* Khoảng cách dưới breadcrumb */
}
.text-primary {
    padding-top: 20px !important;
    padding-bottom: 20px !important;
    background: #FFF;
    box-shadow: var(--bs-box-shadow-sm) !important;
    border-radius: 10px;
    color: #000000 !important; /* Đảm bảo màu đen cho tiêu đề */
    text-align: center;
    margin-bottom: 20px; /* Khoảng cách dưới tiêu đề */
}

.search-bar-wrapper {
    padding-right: 20px;
    padding-left: 20px;
    margin-bottom: 20px; /* Khoảng cách dưới thanh tìm kiếm */
}

/* Gợi ý dành cho bạn - Giao diện Card */
.suggestion-card {
    display: block;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    height: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
}

.suggestion-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(122, 77, 241, 0.3); /* Hiệu ứng shadow màu tím nhẹ */
}

.suggestion-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.suggestion-card:hover .suggestion-card__image {
    transform: scale(1.05);
}

.suggestion-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 60%);
    z-index: 1; /* Đảm bảo overlay nằm trên ảnh */
}

.suggestion-card__title {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    margin: 0;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 2;
}

/* =====================================
   Product List (for HomePage/Category)
   ===================================== */
.product-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* Khoảng cách giữa các sản phẩm */
    padding: 20px;
    justify-content: center;
}

.product-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    width: 250px; /* Chiều rộng cố định cho mỗi sản phẩm */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background-color: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.product-item img {
    max-width: 100%;
    height: 150px; /* Chiều cao cố định cho ảnh */
    object-fit: cover; /* Đảm bảo ảnh không bị méo */
    border-radius: 4px;
    margin-bottom: 10px;
}

.product-item h3 {
    margin: 10px 0;
    font-size: 1.2em;
    font-weight: 700;
    color: #333;
}

.product-item .price {
    font-weight: bold;
    color: #e44d26; /* Màu giá sản phẩm */
    font-size: 1.1em;
    margin-bottom: 15px;
}

.add-to-cart-btn {
    background-color: #ff4d00;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease, transform 0.2s ease;
    width: 100%; /* Nút chiếm hết chiều rộng của item */
    font-weight: 600;
}

.add-to-cart-btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
}

/* =====================================
   Sticky Cart
   ===================================== */
/* Overlay nền đen */
#slide-cart-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 9999;
    display: none;
}
#slide-cart-overlay.show {
    display: block;
}

/* Slide cart full height */
.cart-overlay {
    position: fixed;
    top: 0;
    right: -100%;
    width: 400px;
    max-width: 100%;
    height: 100%;
    background: #fff;
    z-index: 10000;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -2px 0 8px rgba(0,0,0,0.3);
}
.cart-overlay.show {
    right: 0;
}

/* Cart panel nội dung */
.cart-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.cart-body {
    flex-grow: 1;
    overflow-y: auto;
}
.cart-footer {
    border-top: 1px solid #eee;
}
/* Custom styles for Cart Popup */
.cart-item-bordered {
    border-bottom: 1px solid #eee; /* Đường kẻ phân cách */
    margin-bottom: 1rem !important; /* Khoảng cách dưới mỗi món */
    padding-bottom: 1rem !important; /* Khoảng cách nội dung bên trong đường kẻ */
}

/* Đảm bảo đường kẻ cuối cùng không có border-bottom */
.cart-item-bordered:last-of-type {
    border-bottom: none;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Điều chỉnh thêm nếu cần cho nút Thêm món màu cam trên các trang khác */
.btn-warning.add-to-cart-btn {
    background-color: #ff4d00 !important;
    border-color: #ff4d00 !important;
    color: #FFF !important; /* Hoặc màu chữ phù hợp */
}
.btn-warning.add-to-cart-btn:hover {
    background-color: #e0a800 !important; /* Màu đậm hơn khi hover */
    border-color: #e0a800 !important;
}

/* Đảm bảo màu nút "Tiến hành thanh toán" trên footer giỏ hàng cũng giống */
.cart-footer-placeholder .btn-warning {
    background-color: #ff4d00 !important;
    border-color: #ff4d00 !important;
    color: #FFF !important; /* Hoặc màu chữ phù hợp */
}
.cart-footer-placeholder .btn-warning:hover {
    background-color: #e0a800 !important;
    border-color: #e0a800 !important;
}
.main-content-area {margin-top: 0px !important; padding-top: 0px !important;}


/* =====================================
   Responsive Adjustments
   ===================================== */
/* Masonry Grid */
@media (max-width: 1200px) {
    .grid-item { width: calc((100% - 4 * 15px) / 5); } /* 5 cột */
}
@media (max-width: 992px) {
    .grid-item { width: calc((100% - 3 * 15px) / 4); } /* 4 cột */
}
@media (max-width: 768px) {
    .grid-item { width: calc((100% - 2 * 15px) / 3); } /* 3 cột */
    /* Giỏ hàng trên tablet */
    #sticky-cart {
        width: 70px; /* Giảm kích thước trên mobile */
        height: 70px;
        bottom: 15px;
        right: 15px;
    }
    #sticky-cart.expanded {
        width: 280px; /* Chiều rộng mở rộng trên tablet/mobile lớn */
        right: 15px;
    }
    .cart-header, #sticky-cart.expanded .cart-header {
        padding: 10px 15px; /* Giảm padding */
    }
    .cart-body {
        padding: 10px 15px;
    }
}
@media (max-width: 576px) {
    .grid-item { width: calc((100% - 1 * 15px) / 2); } /* 2 cột */
    /* Giỏ hàng trên mobile */
    #sticky-cart {
        width: 60px; /* Giảm kích thước trên mobile nhỏ */
        height: 60px;
        bottom: 10px;
        right: 10px;
    }
    #sticky-cart.expanded {
        width: calc(100% - 20px); /* Chiếm gần hết chiều rộng màn hình */
        right: 10px;
        left: 10px;
    }
    .cart-header, .cart-body {
        padding: 12px 15px; /* Giảm padding trên mobile */
    }
    .product-item {
        width: calc(50% - 10px); /* 2 sản phẩm mỗi hàng trên mobile */
    }
    .product-list {
        gap: 10px;
        padding: 10px;
    }
}
@media (max-width: 420px) { /* Cho màn hình di động rất nhỏ */
    .grid-item { width: 100%; } /* 1 cột */
    .product-item {
        width: 100%; /* 1 sản phẩm mỗi hàng */
    }
}

/* Featured Post Grid */
@media (max-width: 1199px) {
    .custom-post-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 767px) {
    .custom-post-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .custom-post-grid {
        grid-template-columns: 1fr;
    }
}