/* Main container */
.custom-menu-flex {
    display: flex;
    flex-wrap: wrap;
    background-color: #84580B;
    padding: 10px 15px;
    justify-content: flex-start;
}
/* --- CẤP 1: MENU NGANG (lv0) --- */
.menu-level-0 {
    position: relative;
    margin-right: 15px;
}
.menu-level-0 .custom-menu-item {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    white-space: nowrap;
    font-weight: 600;
    text-transform: uppercase;
    position: relative;
    transition: all 0.3s ease;
    border-radius: 6px;
}
.menu-level-0 .custom-menu-item:hover {
    background-color: #c59c41;
    color: white;
}
.menu-arrow {
    margin-left: 5px;
    font-size: 12px;
}
/* --- SUBMENU DROPDOWN LV1 --- */
.menu-level-0 > .submenu-wrapper {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    padding: 15px;
    min-width: 480px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 999;
    flex-wrap: wrap;
    border-radius: 6px;
    gap: 20px;
}
.menu-level-0:hover > .submenu-wrapper {
    display: flex;
}
/* --- LV2 – CÓ THUMB – GRID --- */
.menu-level-1 {
    flex: 1 0 45%;
    max-width: 45%;
    box-sizing: border-box;
}
.menu-level-1 .custom-menu-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px;
    color: #84580B;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 5px;
}
.menu-level-1 .custom-menu-item:hover {
    background-color: #a47414; /* màu đậm hơn lv1 */
    color: #fff;
    font-weight: 600;
    transform: translateY(-2px);
    border-radius: 6px;
}
.menu-level-1 .custom-menu-item:hover .menu-thumb {
    filter: brightness(1.05);
    transform: scale(1.02);
    transition: all 0.3s ease;
}
/* THUMBNAIL */
.menu-thumb {
    width: 70px;
    height: 70px;
    margin-bottom: 6px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    display: block;
}
.menu-child-thumb-placeholder {
    width: 70px;
    height: 70px;
    background-color: #eee;
    border-radius: 5px;
    margin-bottom: 8px;
}
.menu-child-thumb {
    display: flex;
    justify-content: center;
    align-items: center;
}
/* RESPONSIVE */
/* Ẩn menu toggle mặc định desktop */
.menu-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #f9f9f9; /* nền sáng */
    color: #333;
    border: none;
    padding: 8px 15px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
    transition: background-color 0.3s ease;
}
.menu-toggle-btn:hover {
    background-color: #e0e0e0;
}

/* Icon "≡" như hình bạn muốn */
.menu-toggle-btn .menu-icon {
    font-size: 24px;
    line-height: 1;
}

/* Ẩn menu desktop khi nhỏ hơn 992px */
@media (max-width: 991px) {
    .custom-menu-flex {
        display: none;
    }
}

/* Popup menu bên trái */
.mobile-menu-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background-color: #fafafa; /* nền sáng */
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    padding: 20px 15px;
    overflow-y: auto;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

/* Khi active hiện menu */
.mobile-menu-popup.active {
    transform: translateX(0);
}

/* Close button */
.mobile-menu-popup .close-menu {
    font-size: 28px;
    font-weight: 700;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 15px;
    color: #555;
    user-select: none;
}

/* Menu cấp 0 (parent) */
.mobile-menu-popup .menu-level-0 > .custom-menu-item {
    font-weight: 700;
    padding: 10px 5px;
    color: #222;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
}

/* Mũi tên cho toggle submenu */
.mobile-menu-popup .submenu-toggle-icon {
    font-size: 16px;
    transition: transform 0.3s ease;
}

/* Xoay mũi tên khi active */
.mobile-menu-popup .submenu-toggle.open > .submenu-toggle-icon {
    transform: rotate(90deg);
}

/* Submenu wrapper mặc định ẩn */
.mobile-menu-popup .submenu-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

/* Khi mở submenu */
.mobile-menu-popup .submenu-wrapper.open {
    max-height: 1000px; /* đủ cao để hiện hết */
}

/* Menu cấp 1 (con) */
.mobile-menu-popup .menu-level-1 .custom-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: #555;
    font-weight: 500;
    border-bottom: 1px solid #eee;
}

/* Thumbnail trong menu cấp 1 */
.mobile-menu-popup .menu-thumb {
    width: 50px;
    height: 50px;
    border-radius: 5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    object-fit: cover;
}

/* Scrollbar cho popup */
.mobile-menu-popup::-webkit-scrollbar {
    width: 6px;
}
.mobile-menu-popup::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.15);
    border-radius: 3px;
}

/* Tối ưu cho mobile nhỏ */
@media (max-width: 480px) {
    .mobile-menu-popup {
        width: 90vw;
        padding: 15px 10px;
    }
}
/* TOGGLE BTN (nếu dùng) */
.menu-toggle-btn {
    background-color: #84580B;
    color: white;
    padding: 10px 15px;
    font-size: 16px;
    border: none;
    border-radius: 4px;
    margin-bottom: 10px;
    cursor: pointer;
    display: none;
}
@media screen and (max-width: 768px) {
    .menu-toggle-btn {
        display: block;
    }
}
/* CSS buttom */
.menu-toggle-btn {
    background-color: #84580B;
    color: white;
    padding: 10px 15px;
    font-size: 16px;
    border: none;
    border-radius: 4px;
    margin-bottom: 10px;
    cursor: pointer;
    display: none;
}

/* Hiện nút menu trên mobile và tablet */
@media screen and (max-width: 991px) {
    .menu-toggle-btn {
        display: block;
    }
    .custom-menu-flex {
        display: none !important;
        flex-direction: column;
        background: #fff;
        width: 280px; /* chiều rộng sidebar */
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        overflow-y: auto;
        padding: 20px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.15);
        z-index: 9999;
    }
    /* Style menu cấp 0 thành dọc */
    .menu-level-0 {
        margin: 0 0 10px 0;
    }
    .menu-level-0 .custom-menu-item {
        display: flex;
        justify-content: space-between;
        color: #333;
        font-weight: 700;
        text-transform: uppercase;
        padding: 10px 15px;
        background: transparent;
        border-radius: 0;
    }
    /* Các submenu-wrapper ẩn mặc định */
    .submenu-wrapper {
        display: none;
        margin-left: 15px;
        padding-left: 10px;
        border-left: 2px solid #ccc;
    }
    /* Cấp 1 & con */
    .menu-level-1, .menu-level-2 {
        flex: none;
        max-width: 100%;
    }
    .menu-level-1 .custom-menu-item, .menu-level-2 .custom-menu-item {
        padding: 8px 10px;
        font-weight: 500;
        color: #555;
        text-transform: none;
        justify-content: flex-start;
    }
    /* Thumbnail nhỏ ở đầu mục con */
    .menu-child-thumb {
        margin-right: 10px;
    }
    .menu-child-thumb img.menu-thumb {
        width: 40px;
        height: 40px;
        border-radius: 4px;
        box-shadow: none;
    }
    /* Toggle submenu icon */
    .submenu-toggle {
        cursor: pointer;
        font-weight: 700;
        user-select: none;
        margin-right: 10px;
    }
}