.imta-cat-menu {
    --imta-cat-green: #26cf3d;
    --imta-cat-green-dark: #14b72d;
    --imta-cat-text: #3d3d3d;
    --imta-cat-border: #e8e8e8;
    position: relative;
    z-index: 9999;
    display: inline-block;
    color: var(--imta-cat-text);
    font-family: "IMTA SVN Poppins", "Poppins", sans-serif;
    text-align: left;
}

.imta-cat-menu--dropdown {
    z-index: 9990;
    transition: opacity .15s ease, visibility 0s linear 0s;
}

.imta-cat-menu--click.is-open {
    z-index: 10010;
}

.imta-cat-click-menu-open .imta-cat-menu--dropdown {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease, visibility 0s linear .12s;
}

.imta-cat-menu *,
.imta-cat-menu *::before,
.imta-cat-menu *::after {
    box-sizing: border-box;
}

.imta-cat-menu__toggle {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 5px;
    background: #55d968;
    box-shadow: none;
    color: #fff;
    font-family: "IMTA SVN Poppins", "Poppins", sans-serif;
    font-size: 13px;
    font-weight: 400;
    line-height: 1;
    text-transform: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease;
}

.imta-cat-menu__toggle:hover,
.imta-cat-menu__toggle:focus-visible,
.imta-cat-menu.is-open .imta-cat-menu__toggle {
    border-color: rgba(255, 255, 255, .9);
    background: #42cf57;
    color: #fff;
    outline: none;
}

.imta-cat-menu__toggle-icon {
    display: grid;
    width: 23px;
    height: 23px;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 3px;
    transition: background-color .18s ease, border-color .18s ease;
}

.imta-cat-menu.is-open .imta-cat-menu__toggle-icon {
    border-color: #ff8a25;
    background: #ff8a25;
}

.imta-cat-menu.is-open .imta-cat-menu__toggle-icon::before {
    content: "×";
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.imta-cat-menu.is-open .imta-cat-menu__toggle-icon svg {
    display: none;
}

.imta-cat-menu__toggle-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 1.8;
}

.imta-cat-menu__dropdown[hidden],
.imta-cat-menu__panel[hidden] {
    display: none !important;
}

.imta-cat-menu__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(var(--imta-dropdown-offset, 0px)) translateY(-7px) scale(.985);
    transform-origin: top left;
    width: 250px;
    margin: 0;
    padding: 5px 0;
    border: 1px solid rgba(0, 0, 0, .06);
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(0, 0, 0, .22);
    overflow: visible;
    transition: opacity .18s ease-out, transform .2s ease-out, visibility 0s linear .2s;
}

.imta-cat-menu__dropdown.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(var(--imta-dropdown-offset, 0px)) translateY(0) scale(1);
    transition-delay: 0s;
}

.imta-cat-menu--dropdown .imta-cat-menu__dropdown,
.imta-cat-menu--dropdown .imta-cat-menu__dropdown.is-visible {
    position: relative;
    top: auto;
    left: auto;
    width: 250px;
    max-width: 94vw;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

.imta-cat-menu__list {
    position: static;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.imta-cat-menu__entry {
    position: static;
    display: block;
    margin: 0;
    padding: 0 5px;
}

.imta-cat-menu__row {
    display: flex;
    min-height: 34px;
    align-items: center;
    border-radius: 3px;
    transition: background-color .15s ease, color .15s ease;
}

.imta-cat-menu__entry.is-active > .imta-cat-menu__row,
.imta-cat-menu__row:focus-within {
    background: #f1fff3;
    color: var(--imta-cat-green-dark);
}

/* Giữ vùng hover liên tục qua khe 8px giữa danh mục cha và panel. */
.imta-cat-menu__entry.is-active::after {
    content: "";
    position: absolute;
    top: 0;
    left: 100%;
    width: 8px;
    height: 100%;
}

.imta-cat-menu__parent-link {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 7px;
    padding: 5px 4px;
    color: inherit;
    font-family: "IMTA SVN Poppins", "Poppins", sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 24px;
    text-decoration: none;
}

.imta-cat-menu__parent-link:hover,
.imta-cat-menu__parent-link:focus {
    color: var(--imta-cat-green-dark);
}

.imta-cat-menu__parent-thumb {
    display: grid;
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    place-items: center;
}

.imta-cat-menu__parent-thumb .imta-cat-menu__image {
    width: 25px;
    height: 25px;
    object-fit: contain;
}

.imta-cat-menu__parent-name {
    min-width: 0;
    white-space: nowrap;
}

.imta-cat-menu__expand {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: #666;
    cursor: pointer;
}

.imta-cat-menu__expand:hover,
.imta-cat-menu__expand:focus-visible {
    background: transparent;
    color: var(--imta-cat-green-dark);
    outline: 2px solid rgba(38, 207, 61, .25);
    outline-offset: -3px;
}

.imta-cat-menu__expand svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.imta-cat-menu__panel {
    position: absolute;
    top: -1px;
    left: calc(100% + 8px);
    width: var(--imta-panel-width, min(940px, calc(100vw - 300px)));
    min-height: calc(100% + 2px);
    max-height: 76vh;
    padding: 10px;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(0, 0, 0, .2);
    overflow: auto;
}

.imta-cat-menu__panel-title {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 0 10px;
    padding: 0;
    color: var(--imta-cat-text);
    font-family: "IMTA SVN Poppins", "Poppins", sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    text-transform: none;
}

.imta-cat-menu__panel-title a {
    color: inherit;
    text-decoration: none;
}

.imta-cat-menu__panel-title a:hover {
    color: var(--imta-cat-green-dark);
}

.imta-cat-menu__grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    gap: 12px;
}

.imta-cat-menu__card {
    display: flex;
    min-width: 0;
    min-height: 170px;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 8px 12px;
    border: 1px solid var(--imta-cat-border);
    border-radius: 3px;
    background: #fff;
    color: #4a4a4a;
    text-align: center;
    text-decoration: none;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.imta-cat-menu__card:hover,
.imta-cat-menu__card:focus-visible {
    border-color: rgba(38, 207, 61, .65);
    box-shadow: 0 5px 14px rgba(0, 0, 0, .08);
    color: var(--imta-cat-green-dark);
    outline: none;
    transform: translateY(-2px);
}

.imta-cat-menu__card-image {
    display: grid;
    width: 100%;
    height: 115px;
    place-items: center;
}

.imta-cat-menu__card-image .imta-cat-menu__image {
    width: 100%;
    height: 115px;
    object-fit: contain;
}

.imta-cat-menu__card-name {
    display: block;
    width: 100%;
    font-family: "IMTA SVN Poppins", "Poppins", sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.35;
}

.imta-cat-menu__image--fallback {
    display: grid;
    place-items: center;
    color: #b7b7b7;
}

.imta-cat-menu__image--fallback svg {
    width: 72%;
    height: 72%;
    fill: currentColor;
}

.imta-parent-categories {
    width: 100%;
    color: var(--imta-cat-text);
    font-family: "IMTA SVN Poppins", "Poppins", sans-serif;
}

.imta-parent-categories *,
.imta-parent-categories *::before,
.imta-parent-categories *::after {
    box-sizing: border-box;
}

.imta-parent-categories__list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.imta-parent-categories__item {
    min-width: 0;
    margin: 0;
    padding: 0;
    margin-left: 0px !important;
}

.imta-parent-categories__item > a {
    display: flex;
    min-height: 146px;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 3px 2px;
    color: rgb(63, 63, 63) !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.55;
    text-align: center;
    text-decoration: none;
    transition: color .18s ease, transform .18s ease;
}

.imta-parent-categories__item > a:hover,
.imta-parent-categories__item > a:focus-visible {
    color: var(--imta-cat-green-dark);
    outline: none;
    transform: translateY(-3px);
}

.imta-parent-categories__image {
    display: grid;
    width: 96px;
    height: 96px;
    flex: 0 0 96px;
    place-items: center;
}

.imta-parent-categories__image .imta-cat-menu__image {
    width: 96px;
    height: 96px;
    object-fit: contain;
}

.imta-parent-categories__name {
    display: block;
    width: 100%;
}

@media (max-width: 1100px) and (min-width: 850px) {
    .imta-cat-menu__panel {
        width: var(--imta-panel-width, min(680px, calc(100vw - 285px)));
    }

    .imta-cat-menu__grid {
        grid-template-columns: repeat(4, minmax(105px, 1fr));
    }
}

@media (max-width: 849px) {
    .imta-cat-menu {
        z-index: 100000;
    }

    .imta-cat-menu__dropdown {
        left: 0;
        transform: translateX(var(--imta-dropdown-offset, 0px)) translateY(-7px) scale(.985);
        width: min(94vw, 370px);
        max-height: min(76vh, 650px);
        overflow-x: hidden;
        overflow-y: auto;
    }

    .imta-cat-menu__dropdown.is-visible {
        transform: translateX(var(--imta-dropdown-offset, 0px)) translateY(0) scale(1);
    }

    .imta-cat-menu__entry {
        position: relative;
    }

    .imta-cat-menu__entry.is-active::after {
        display: none;
    }

    .imta-cat-menu__panel {
        position: static;
        width: 100%;
        min-height: 0;
        max-height: none;
        margin: 3px 0 8px;
        padding: 9px 5px 7px 32px;
        border: 0;
        border-top: 1px solid #edf0ed;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    .imta-cat-menu__entry.is-active .imta-cat-menu__expand svg {
        transform: rotate(90deg);
    }

    .imta-cat-menu__panel-title {
        font-size: 15px;
    }

    .imta-cat-menu__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .imta-cat-menu__card {
        min-height: 135px;
        padding: 7px;
    }

    .imta-cat-menu__card-image,
    .imta-cat-menu__card-image .imta-cat-menu__image {
        height: 86px;
    }

    .imta-cat-menu__card-name {
        font-size: 13px;
    }

    .imta-parent-categories__list {
        grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
        gap: 8px;
    }

    .imta-parent-categories__item > a {
        min-height: 126px;
        font-size: 13px;
    }

    .imta-parent-categories__image,
    .imta-parent-categories__image .imta-cat-menu__image {
        width: 78px;
        height: 78px;
    }

    /* Mobile: luôn hiển thị 5 danh mục trên một hàng, kể cả tên danh mục dài. */
    .imta-parent-categories__list {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 5px;
    }

    .imta-parent-categories__item > a {
        min-height: 0;
        gap: 4px;
        font-size: clamp(8px, 3vw, 11px);
        line-height: 1.15;
        text-align: center;
    }

    .imta-parent-categories__image,
    .imta-parent-categories__image .imta-cat-menu__image {
        width: clamp(45px, 13vw, 70px);
        height: clamp(45px, 13vw, 70px);
    }

}

@media (prefers-reduced-motion: reduce) {
    .imta-cat-menu *,
    .imta-cat-menu *::before,
    .imta-cat-menu *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* Thanh điều hướng cố định ở đáy màn hình chỉ dành cho thiết bị di động. */
.imta-mobile-bottom-menu,
.imta-mobile-category-drawer {
    display: none;
}

@media (max-width: 849px) {
    body {
        padding-bottom: 64px;
    }

    .imta-mobile-bottom-menu {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 100020;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        min-height: 60px;
        border-top: 1px solid rgba(255, 255, 255, .45);
        background: #25c93d;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, .16);
    }

    .imta-mobile-bottom-menu__item {
        display: flex;
        min-width: 0;
        min-height: 60px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 5px 3px 4px;
        border: 0;
        border-right: 1px solid rgba(255, 255, 255, .34);
        border-radius: 0;
        background: transparent;
        color: #fff;
        font: 500 11px/1.15 "IMTA SVN Poppins", "Poppins", sans-serif;
        text-align: center;
        text-decoration: none;
        margin:0;
    }

    .imta-mobile-bottom-menu__item:last-child {
        border-right: 0;
        background: #ff8b26;
    }

    .imta-mobile-bottom-menu__item svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }

    .imta-mobile-bottom-menu__item span {
        display: block;
    }

    .imta-mobile-bottom-menu__item[aria-disabled="true"] {
        opacity: .65;
    }

    .imta-mobile-category-drawer {
        position: fixed;
        z-index: 100030;
        display: block;
        inset: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .imta-mobile-category-drawer.is-open {
        visibility: visible;
        pointer-events: auto;
    }

    .imta-mobile-category-drawer__backdrop {
        position: absolute;
        inset: 0;
        border: 0;
        background: rgba(0, 0, 0, .48);
        opacity: 0;
        transition: opacity .25s ease;
        width: 100%;
        height: 100%;
    }

    .imta-mobile-category-drawer__panel {
        position: relative;
        display: flex;
        width: min(70vw, 390px);
        height: 100%;
        flex-direction: column;
        background: #fff;
        box-shadow: 4px 0 18px rgba(0, 0, 0, .24);
        transform: translateX(-100%);
        transition: transform .28s ease;
    }

    .imta-mobile-category-drawer.is-open .imta-mobile-category-drawer__backdrop {
        opacity: 1;
    }

    .imta-mobile-category-drawer.is-open .imta-mobile-category-drawer__panel {
        transform: translateX(0);
    }

    .imta-mobile-category-drawer__header {
        display: flex;
        min-height: 54px;
        align-items: center;
        justify-content: space-between;
        padding: 0 14px 0 18px;
        background: #25c93d;
        color: #fff;
    }

    .imta-mobile-category-drawer__header h2 {
        margin: 0;
        color: inherit;
        font: 600 17px/1.2 "IMTA SVN Poppins", "Poppins", sans-serif;
    }

    .imta-mobile-category-drawer__header button {
        width: 41px;
        height: 24px;
        border: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, .18);
        color: #fff;
        line-height: 1;
        margin: 0;
        padding: 5px;
    }

    .imta-mobile-category-drawer__content {
        flex: 1;
        padding: 10px;
        overflow-y: auto;
    }

    .imta-mobile-category-drawer .imta-cat-menu,
    .imta-mobile-category-drawer .imta-cat-menu--dropdown,
    .imta-mobile-category-drawer .imta-cat-menu--dropdown .imta-cat-menu__dropdown {
        display: block;
        width: 100%;
        max-width: none;
    }

    .imta-mobile-category-drawer .imta-cat-menu__dropdown {
        max-height: none;
        border: 0;
        box-shadow: none;
    }

    .imta-mobile-category-drawer .imta-cat-menu__entry {
        padding: 0;
    }

    .imta-mobile-category-drawer .imta-cat-menu__row {
        min-height: 52px;
        border-bottom: 1px solid #edf0ed;
    }

    .imta-mobile-category-drawer .imta-cat-menu__panel {
        padding-left: 0;
    }

    /* Panel con phải mở ngay khi người dùng nhấn mũi tên danh mục. */
    .imta-mobile-category-drawer .imta-cat-menu__entry.is-active > .imta-cat-menu__panel {
        display: block !important;
    }

    .imta-mobile-category-drawer-open {
        overflow: hidden;
    }
}
