/* ================================================================
   Layout chung – Mega menu, Duyệt danh mục (dùng cho mọi trang)
   Include: <link rel="stylesheet" href="layout/head-common.css" />
   ================================================================ */

/* Wrapper search box cần position:relative để menu bám theo */
.search-style-2 { position: relative; }

/* NÚT "DUYỆT DANH MỤC" – hover effect */
.categories-button-active {
    transition: background 0.25s ease, box-shadow 0.25s ease,
                transform 0.2s ease, color 0.2s ease !important;
    will-change: transform, box-shadow;
}
.categories-button-active:hover {
    background: #258f5a !important;
    color: #fff !important;
    box-shadow: 0 6px 24px rgba(37, 143, 90, 0.45) !important;
    transform: translateY(-3px) scale(1.02) !important;
}
.categories-button-active:active {
    transform: translateY(0) scale(1) !important;
    box-shadow: 0 2px 12px rgba(37, 143, 90, 0.3) !important;
}

/* Panel mega-menu */
#menuCategories {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 24px 20px;
    width: 860px;
    max-width: 98vw;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.12);
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 9999;
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}
.search-style-2:hover #menuCategories {
    opacity: 1;
    visibility: visible;
}

#menuCategories > li.sub-mega-menu {
    flex: 0 0 25%;
    box-sizing: border-box;
    padding: 10px 14px;
    border-right: 1px solid #f5f5f5;
}
#menuCategories > li.sub-mega-menu:last-child { border-right: none; }

#menuCategories .menu-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 700;
    color: #253D4E;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 10px;
}
#menuCategories .menu-title:hover { color: #3BB77E; }
#menuCategories .menu-title .parent-icon img {
    width: 18px; height: 18px; object-fit: contain;
}

#menuCategories .sub-mega-menu > ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
#menuCategories .sub-mega-menu > ul > li {
    margin-bottom: 5px;
    position: relative;
}
#menuCategories .sub-mega-menu > ul > li > a {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    padding: 3px 4px;
    border-radius: 5px;
    transition: background 0.15s, color 0.15s;
}
#menuCategories .sub-mega-menu > ul > li > a:hover {
    color: #3BB77E;
    background: #f3fbf8;
}
#menuCategories .sub-mega-menu > ul > li > a .child-icon img {
    width: 14px; height: 14px; object-fit: contain;
}

.level-3-menu {
    list-style: none !important;
    margin: 4px 0 4px 16px !important;
    padding: 0 0 0 10px !important;
    border-left: 2px solid #d4f0e4;
}
.level-3-menu li { margin-bottom: 4px !important; }
.level-3-menu li a {
    font-size: 12px;
    color: #888 !important;
    text-decoration: none;
    display: block;
    padding: 2px 0;
}
.level-3-menu li a:hover { color: #3BB77E !important; }

/* BROWSE ALL CATEGORIES – dropdown sổ xuống ngay dưới nút */
.main-categori-wrap .categories-dropdown-active-large.open {
    top: 100% !important;
    margin-top: 4px !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    z-index: 9999 !important;
}
.main-categori-wrap {
    position: relative !important;
}
.main-categori-wrap .categories-dropdown-active-large {
    position: absolute !important;
    left: 0 !important;
}
.categories-dropdown-wrap,
.categories-dropdown-wrap .d-flex.categori-dropdown-inner {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

#browseCategoriesList {
    padding: 8px;
    margin: 0;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    box-sizing: border-box;
}

#browseCategoriesList > .cat-item {
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
}
#browseCategoriesList > .cat-item > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: #253D4E;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    background: #fff;
    border: 1px solid #e6eef0;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
                transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    width: 100%;
}
#browseCategoriesList > .cat-item > a img {
    width: 22px; height: 22px; object-fit: contain; flex: 0 0 auto;
    transition: transform 0.2s ease;
}
#browseCategoriesList > .cat-item > a:hover {
    background: #f3fbf8;
    color: #3BB77E;
    border-color: #3BB77E;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 183, 126, 0.15);
}
#browseCategoriesList > .cat-item > a:hover img {
    transform: scale(1.15) rotate(-5deg);
}
/* Không hiển thị chevron và menu con khi hover (chỉ 1 cấp danh mục) */
#browseCategoriesList > .cat-item > a::after,
#browseCategoriesList > .cat-item.has-children > a::after {
    content: none !important;
}

#browseCategoriesList .browse-submenu {
    display: none !important;
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 220px;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.10);
    padding: 8px 0;
    z-index: 10002;
    list-style: none;
    margin: 0;
}
#browseCategoriesList > .cat-item.has-children:hover > .browse-submenu {
    display: none !important;
}
#browseCategoriesList .browse-submenu > li > a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: #444;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
#browseCategoriesList .browse-submenu > li > a img {
    width: 16px; height: 16px; object-fit: contain;
}
#browseCategoriesList .browse-submenu > li > a:hover {
    background: #f3fbf8;
    color: #3BB77E;
}
#browseCategoriesList .browse-submenu > li {
    position: relative;
}
#browseCategoriesList .browse-submenu > li.has-children > a::after {
    content: "›";
    margin-left: auto;
    font-size: 15px;
    color: #aaa;
}
#browseCategoriesList .browse-submenu .browse-submenu-lv3 {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 200px;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.10);
    padding: 8px 0;
    z-index: 10003;
    list-style: none;
    margin: 0;
}
#browseCategoriesList .browse-submenu > li.has-children:hover > .browse-submenu-lv3 {
    display: block;
}
#browseCategoriesList .browse-submenu-lv3 li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    color: #555;
    font-size: 12.5px;
    text-decoration: none;
}
#browseCategoriesList .browse-submenu-lv3 li a:hover {
    background: #f3fbf8;
    color: #3BB77E;
}

/* Logo Sang Hà — kích thước ổn định header / footer */
img.sangha-brand-logo {
    max-height: 52px;
    width: auto;
    object-fit: contain;
    display: block;
}
img.sangha-brand-logo.sangha-footer-logo {
    max-height: 44px;
}

/* Mini-cart: mở tạm sau khi thêm vào giỏ (bổ sung cho :hover) */
.header-action-2 .header-action-icon-2.sangha-mini-cart-host.sangha-cart-dropdown-open .cart-dropdown-wrap {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 10px);
}
.header-action .header-action-icon.sangha-mini-cart-host.sangha-cart-dropdown-open .cart-dropdown-wrap {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 10px);
}

/* Giữ dropdown giỏ mở khi di chuột từ icon xuống panel (tránh khe hở làm mất :hover) */
.header-action-2 .header-action-icon-2.sangha-mini-cart-host:hover .cart-dropdown-wrap,
.header-action-2 .header-action-icon-2.sangha-mini-cart-host:focus-within .cart-dropdown-wrap,
.header-action-2 .header-action-icon-2.sangha-mini-cart-host .cart-dropdown-wrap:hover {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 10px);
}
.header-action .header-action-icon.sangha-mini-cart-host:hover .cart-dropdown-wrap,
.header-action .header-action-icon.sangha-mini-cart-host:focus-within .cart-dropdown-wrap,
.header-action .header-action-icon.sangha-mini-cart-host .cart-dropdown-wrap:hover {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 10px);
}
.header-action-2 .header-action-icon-2.sangha-mini-cart-host {
    padding-bottom: 12px;
    margin-bottom: -12px;
}

/* Chặn badge tĩnh từ template cũ: chỉ hiển thị badge giỏ động khi JS sync dữ liệu thật */
.header-action-2 .pro-count:not(.sangha-header-cart-count),
.header-action .pro-count:not(.sangha-header-cart-count) {
    display: none !important;
}

/* Giảm khoảng trắng thừa (breadcrumb + banner cửa hàng + nội dung) */
.page-header.breadcrumb-wrap {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}
#layout-main .page-header.mt-30.mb-50 {
    margin-top: 12px !important;
    margin-bottom: 16px !important;
}
#layout-main .archive-header {
    padding: 20px 24px !important;
    background-size: cover;
}
#layout-main .archive-header h1.mb-15 {
    margin-bottom: 8px !important;
    font-size: 1.65rem !important;
}
#layout-main .container.mb-80.mt-50 {
    margin-top: 24px !important;
    margin-bottom: 40px !important;
}
.main.pages .page-content.pt-150.pb-150 {
    padding-top: 40px !important;
    padding-bottom: 48px !important;
}

/* --- Auth: chỉ dùng class trên body (sangha-auth-ui.js không set style.display từng node) --- */
body.sangha-auth-logged-out .sangha-auth-user {
    display: none !important;
}
body.sangha-auth-logged-in .sangha-auth-guest {
    display: none !important;
}
/* Đã đăng nhập: hiện lại menu user (ghi đè display:none trong HTML) */
body.sangha-auth-logged-in .header-info > ul > li.sangha-auth-user {
    display: list-item !important;
}
body.sangha-auth-logged-in .header-action-2 > .header-action-icon-2.sangha-auth-user,
body.sangha-auth-logged-in .header-action-right .header-action-2 > .header-action-icon-2.sangha-auth-user {
    display: flex !important;
}
/* Khách: luôn hiện icon Đăng nhập cạnh So sánh / Giỏ (đồng bộ với rule user khi đã login) */
body.sangha-auth-logged-out .header-action-2 > .header-action-icon-2.sangha-auth-guest,
body.sangha-auth-logged-out .header-action-right .header-action-2 > .header-action-icon-2.sangha-auth-guest {
    display: flex !important;
}
/* Dropdown đăng nhập/đăng ký: giữ mở khi hover (tránh khe giữa icon và panel) */
.header-action-2 .header-action-icon-2.sangha-auth-guest:hover .cart-dropdown-wrap,
.header-action-2 .header-action-icon-2.sangha-auth-guest:focus-within .cart-dropdown-wrap,
.header-action-2 .header-action-icon-2.sangha-auth-guest .cart-dropdown-wrap:hover {
    opacity: 1;
    visibility: visible;
    top: calc(100% + 10px);
}
.header-action-2 .header-action-icon-2.sangha-auth-guest {
    padding-bottom: 12px;
    margin-bottom: -12px;
}
body.sangha-auth-logged-in .single-mobile-header-info.sangha-auth-user {
    display: block !important;
}
/* Trạng thái khách: luôn ẩn link Quản trị (script admin có thể bật sau) */
body.sangha-auth-logged-out .sangha-admin-only {
    display: none !important;
}

/* Header top: icon + nhãn Đăng nhập / Yêu thích / … */
.header-info > ul > li > a i[class^='fi-rs'] {
    vertical-align: -0.08em;
    opacity: 0.92;
}
.mobile-header-info-wrap .single-mobile-header-info a i[class^='fi-rs'] {
    margin-right: 6px;
    vertical-align: -0.06em;
}
