/* Ô "Menu con xếp theo" (Quản trị → Menu → mục có menu con → "Menu con xếp theo").
   Class menu-sub-horizontal / menu-sub-vertical do core gắn vào <li> của mục cha
   (menu_resolve_items trong app/Helpers/AppHelper.php); file này được generate_menu() nạp
   chỉ khi menu có mục dùng. Mục bật mega cũng nhận class — khối "MEGA" cuối file, thay cho
   cách chia cột của ô Columns (để "Theo giao diện" thì mega giữ nguyên).

   Chỉ đổi CÁCH XẾP các mục con. Ẩn/hiện khi rê chuột vẫn là của theme: mọi theme đều ẩn
   menu con bằng opacity/visibility (thẻ ul luôn display:block), nên đổi ul sang flex không
   phá cơ chế đó.
   Chỉ áp từ 992px: dưới đó là menu điện thoại, menu con luôn xếp dọc.
   Hai họ selector như mega-menu-fit.css: .header .header-menu (Danang24h, Dhome) và
   .vne_header .vne-menu (các theme còn lại). Vietago menu desktop là sidebar dọc nên không
   có tác dụng ở đó. */

@media (min-width: 992px) {

    /* --- Ngang: các mục con nằm trên một hàng; nhiều quá khung thì xuống hàng --- */
    .header .header-menu li.menu-sub-horizontal > .menu-dropdown,
    .vne_header .vne-menu li.menu-sub-horizontal > .menu-dropdown {
        display: flex !important;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        width: max-content !important;
        min-width: 0 !important;
        max-width: min(1000px, calc(100vw - 40px));
    }

    .header .header-menu li.menu-sub-horizontal > .menu-dropdown > li,
    .vne_header .vne-menu li.menu-sub-horizontal > .menu-dropdown > li {
        position: relative;
        display: block !important;
        flex: 0 0 auto;
        width: auto !important;
    }

    /* Vài theme kẻ gạch dưới giữa các mục (hợp với cột dọc) — xếp ngang thì bỏ */
    .header .header-menu li.menu-sub-horizontal > .menu-dropdown > li > a,
    .vne_header .vne-menu li.menu-sub-horizontal > .menu-dropdown > li > a {
        white-space: nowrap;
        border-bottom: 0 !important;
    }

    /* Mũi tên của mục con có menu cấp tiếp theo: theme đặt position:absolute sát mép phải
       thẻ a (Danang24h: .main-menu i.caret). Ở cột dọc mục rộng ≥ 200px nên không chạm chữ;
       xếp ngang mục co vừa chữ ⇒ mũi tên đè lên chữ cuối. Cho nó nằm ngay sau chữ. */
    .header .header-menu li.menu-sub-horizontal > .menu-dropdown > li > a > .caret,
    .vne_header .vne-menu li.menu-sub-horizontal > .menu-dropdown > li > a > .caret {
        position: static !important;
        width: auto !important;
        height: auto !important;
        margin-left: 6px;
    }

    /* Mục con của hàng ngang mà có menu cấp tiếp theo: rơi xuống ngay dưới mục đó,
       thay vì bay sang phải (kiểu của cột dọc) và đè lên mục bên cạnh */
    .header .header-menu li.menu-sub-horizontal > .menu-dropdown > li > .menu-dropdown,
    .vne_header .vne-menu li.menu-sub-horizontal > .menu-dropdown > li > .menu-dropdown {
        top: 100% !important;
        left: 0 !important;
    }

    /* --- Dọc: mỗi mục con một dòng. Đang là mặc định của mọi theme; chọn ô này để giữ
           dọc kể cả khi theme sau này đổi mặc định --- */
    .header .header-menu li.menu-sub-vertical > .menu-dropdown,
    .vne_header .vne-menu li.menu-sub-vertical > .menu-dropdown {
        flex-direction: column;
    }

    .header .header-menu li.menu-sub-vertical > .menu-dropdown > li,
    .vne_header .vne-menu li.menu-sub-vertical > .menu-dropdown > li {
        display: block !important;
        width: 100%;
    }

    /* ===== MEGA (mục bật "Enable mega menu") =====
       Cấu trúc: li.-has-mega-menu > div.mega > ul.subnav > li. Theme cho .mega rộng cố định
       (700px, hoặc theo column-N) và mỗi mục con một tỉ lệ % ⇒ ít mục thì thừa chỗ, nhiều mục
       thì tự xuống dòng (VD 6 khách sạn ra 4 + 2). Ở đây khung rộng theo nội dung; chỉ lo KÍCH
       THƯỚC, vị trí + ẩn/hiện (opacity/pointer-events) giữ theo theme. */

    /* Ngang: mỗi mục con một cột trên cùng một hàng (giống Columns = "Vừa nội dung") */
    .header .header-menu li.menu-sub-horizontal > .mega,
    .vne_header .vne-menu li.menu-sub-horizontal > .mega {
        width: max-content !important;
        max-width: calc(100vw - 40px);
    }

    .header .header-menu li.menu-sub-horizontal > .mega > .subnav,
    .vne_header .vne-menu li.menu-sub-horizontal > .mega > .subnav {
        flex: 0 1 auto;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .header .header-menu li.menu-sub-horizontal > .mega > .subnav > li,
    .vne_header .vne-menu li.menu-sub-horizontal > .mega > .subnav > li {
        flex: 0 0 auto;
        width: auto !important;
        max-width: 280px;
    }

    /* Dọc: các mục con thành một cột */
    .header .header-menu li.menu-sub-vertical > .mega,
    .vne_header .vne-menu li.menu-sub-vertical > .mega {
        width: max-content !important;
        min-width: 220px;
        max-width: calc(100vw - 40px);
    }

    .header .header-menu li.menu-sub-vertical > .mega > .subnav,
    .vne_header .vne-menu li.menu-sub-vertical > .mega > .subnav {
        flex: 0 1 auto;
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .header .header-menu li.menu-sub-vertical > .mega > .subnav > li,
    .vne_header .vne-menu li.menu-sub-vertical > .mega > .subnav > li {
        width: auto !important;
    }
}
