/* ===========================================================
   NAVBAR COMPONENT — navbar.css (Mobile-First Architecture)
   =========================================================== */

/* ── 1. CORE LAYOUT & VARIABLES ── */
#main-content {
    padding-top: 0; /*var(--nav-height, 100px);*/
}

.km-navbar {
    position: sticky;
    top: 0;
    /* bỏ inset: 0 0 auto 0 cũ — đó là để "neo" full-width cho fixed,
     sticky không cần vì div block đã tự full-width theo luồng bình thường */
    /*inset: auto; */

    z-index: 1050;
    background: var(--km-green, #00aa5a);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    /*box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.12);*/
    height: var(--nav-height, 100px);
    padding: 0;
    transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s ease, background-color 0.35s ease;
}

.km-navbar__inner {
    display: grid;
    grid-template-columns: 40% 60%;
    height: 100%;
    align-items: center;
}

/* ── 2. BRAND COLUMN ── */
.km-brand-col {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.km-brand-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    height: 100%;
    width: 100%;
}

.km-brand__img {
    height: 60px;
    width: auto;
    object-fit: contain;
    transition: transform 0.25s ease, height 0.35s ease;
}

.km-brand-link:hover .km-brand__img {
    transform: scale(1.04);
}

.km-brand__text {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 0.625rem;
    font-weight: 400;
    color: #ffffff;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.2;
    margin-top: 6px;
}

/* ── 3. CONTENT COLUMN (SLOGAN & MENU ROWS) ── */
.km-content-col {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Slogan Row (Tính theo biến --slogan-height hoặc calc 100px - 55px = 45px) */
.km-slogan-row {
    height: var(--slogan-height, calc(var(--nav-height, 100px) - var(--menu-height, 55px)));
    display: flex;
    align-items: last baseline;
    justify-content: flex-start;
    overflow: hidden;
    opacity: 1;
    transition: height 0.3s ease, opacity 0.25s ease;
    /* Đẩy Slogan row sang trai ..px */
    margin-left: -50px;
}

.km-slogan {
    font-family: 'Baloo 2', 'Be Vietnam Pro', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    /*color: #ffe14d;*/
    color: yellow;
    line-height: 1.2;
    text-transform: uppercase;
    transform: translateY(2px);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    animation: slogan-appear-flip 6s ease-in-out infinite;
    white-space: nowrap;
    /*margin-left: -5%
    margin-left: -0px;
    padding-left: 0px;;*/
}

@keyframes slogan-appear-flip {
    0% {
        opacity: 0;
        transform: translateY(2px) rotateX(-90deg);
    }

    10%, 90% {
        opacity: 1;
        transform: translateY(2px) rotateX(0deg);
    }

    100% {
        opacity: 0;
        transform: translateY(2px) rotateX(90deg);
    }
}

/* Menu Row & Hamburger Toggler (Mobile Base) */
.km-menu-row {
    height: var(--menu-height, 55px);
    display: flex;
    align-items: center;
    margin-top: 5px; /* Đẩy menu row xuống 5px */

}

.km-toggler {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    outline: none;
}

.km-toggler-text {
    color: #ffffff;
    font-size: 0.75rem; /* 12px */
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 2px #000;
}

.km-toggler-icon {
    width: 22px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

    .km-toggler-icon span {
        display: block;
        width: 100%;
        height: 3px;
        background-color: #ffe14d;
        border-radius: 2px;
        box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.9), 0 -1px 0px rgba(0, 0, 0, 0.7);
        transition: all 0.25s ease;
    }

/* ── 4. NAVIGATION LINKS & DROPDOWN (Mobile / Default) ── */
.km-menu {
    width: 100%;
}

    .km-menu.collapse:not(.show) {
        display: none;
    }

    .km-menu.collapse.show {
        display: block;
        position: absolute;
        top: var(--nav-height, 100px);
        left: 0;
        width: 100%;
        background: var(--km-green, #00aa5a);
        padding: 1rem;
        box-shadow: 0 10px 10px rgba(0, 0, 0, 0.2);
    }

.km-nav {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    height: auto;
}

.km-nav__item {
    width: 100%;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.km-nav__link {
    display: flex;
    align-items: center;
    padding: 0.75rem 0.5rem !important;
    color: #ffffff !important; /* Đảm bảo chữ trắng trên nền xanh */
    font-size: 0.750rem;
    font-weight: 400;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.km-dropdown {
    display: none;
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px, 8px;
}

    .km-dropdown.show {
        display: block;
    }

.km-dropdown__item {
    color: #ffffff !important;
    font-size: 0.875rem;
    padding: 0.6rem 1.1rem;
    text-decoration: none;
    display: block;
    border-radius: 4px;
    transition: all 0.2s ease;
}

/* Hover/Active hiệu ứng Mobile (< 992px) */
@media (max-width: 991.98px) {
    .km-nav__link:hover,
    .km-nav__link:focus,
    .km-nav__link:active,
    .km-nav__link.active {
        background-color: rgba(255, 255, 255, 0.12);
        color: #ffe14d !important;
        text-decoration: underline;
        text-underline-offset: 4px;
        padding-left: 0.8rem !important;
    }

    .km-dropdown__item:hover,
    .km-dropdown__item:active {
        background-color: rgba(255, 255, 255, 0.2);
        color: #ffe14d !important;
        text-decoration: underline;
        text-underline-offset: 3px;
    }
}

/* ── 4b. SCROLLED STATE (toggle bởi navbar.js khi window.scrollY > 40px) ── */
.km-navbar.is-scrolled {
    /* Ghi đè biến --nav-height ngay tại đây, mọi phần tử con dùng var(--nav-height)
       (slogan-row, .km-menu.collapse.show top...) sẽ tự động co theo, không cần sửa gì thêm */
    --nav-height: 64px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14), 0 10px 20px rgba(0, 0, 0, 0.10), 0 20px 36px rgba(0, 0, 0, 0.06); /* shadow nhiều lớp tạo cảm giác "nổi" khi cuộn */
}

    .km-navbar.is-scrolled .km-brand__img {
        height: 42px;
    }

    .km-navbar.is-scrolled .km-slogan-row {
        height: 0;
        opacity: 0;
        pointer-events: none;
    }

@media (min-width: 992px) {
    .km-navbar.is-scrolled {
        --nav-height: 68px;
    }

        .km-navbar.is-scrolled .km-brand__img {
            height: 48px;
        }
}

/* ── 5. RESPONSIVE: EXTRA SMALL DEVICES (< 576px) ── */
@media (max-width: 575.98px) {
    .km-navbar {
        height: auto !important;
        min-height: var(--nav-height, 100px);
        padding: 6px 0;
    }

    .km-navbar__inner {
        height: auto !important;
        grid-template-columns: 35% 65%;
    }

    .km-brand-col,
    .km-content-col {
        height: auto !important;
    }

    .km-brand__img {
        height: 42px;
    }

    .km-brand__text {
        font-size: 0.438rem; /* ~7px */
        margin-top: 3px;
    }

    .km-slogan-row {
        height: auto !important;
        padding-top: 4px;
        justify-content: flex-start;
    }

    .km-slogan {
        font-size: 0.75rem;
        white-space: normal;
        text-align: left;
        margin-left: auto;
    }

    .km-menu-row {
        height: auto !important;
        margin-top: 5px !important;
    }

    .km-toggler {
        padding: 2px 4px;
    }

    .km-toggler-text {
        font-size: 0.625rem; /* ~11px */
    }

    .km-nav__link {
        font-size: 0.625rem; /* ~11px cho màn nhỏ */
    }

    .km-menu.collapse.show {
        top: 100%;
    }
}

/* ── 6. RESPONSIVE: DESKTOP EXPANSION (>= 992px) ── */
@media (min-width: 992px) {
    .km-navbar__inner {
        grid-template-columns: 25% 75%;
    }

    .km-slogan {
        font-size: 1.375rem;
        transform: translateY(4px);
        /*margin-left: -30px;*/
        /*padding-left: 0px;*/
    }
    .km-menu-spacer {
        width: 30px;
        /* kéo cả .km-menu (mọi item bên trong) dịch phải 30px */
        /*margin-left: -45px;
        padding: 0px;*/
    }
    @keyframes slogan-appear-flip {
        0% {
            opacity: 0;
            transform: translateY(2px) rotateX(-90deg);
        }

        10%, 90% {
            opacity: 1;
            transform: translateY(3px) rotateX(0deg);
        }

        100% {
            opacity: 0;
            transform: translateY(4px) rotateX(90deg);
        }
    }

    .km-menu.collapse:not(.show),
    .km-menu.collapse.show {
        display: block !important;
        position: static;
        background: transparent;
        padding: 0;
        box-shadow: none;
    }

    .km-nav {
        flex-direction: row;
        height: var(--menu-height, 55px);
    }

    .km-nav__item {
        width: auto;
        height: 100%;
        display: flex;
        align-items: center;
        border-bottom: none;
    }

    /* Yêu cầu: Cỡ chữ menu link đúng 14px (0.875rem) */
    .km-nav__link {
        position: relative;
        display: inline-flex;
        align-items: center;
        height: 100%;
        padding: 0 0.8rem !important;
        white-space: nowrap;
        border-radius: 0;
        color: #ffffff !important;
        font-size: 0.875rem !important;
        font-weight: 600;
    }

        .km-nav__link:hover,
        .km-nav__link:focus,
        .km-nav__link:active {
            background-color: transparent;
            padding-left: 0.8rem !important;
            text-decoration: none;
        }

        /* Đường gạch chân hover Desktop */
        .km-nav__link::before {
            content: "";
            position: absolute;
            left: 50%;
            bottom: calc(50% - (1em / 2) - 8px);
            width: 0;
            height: 2px;
            background: #ffe14d;
            transform: translateX(-50%);
            transition: width 0.25s ease, opacity 0.25s ease;
            opacity: 0;
        }

        .km-nav__link:hover::before,
        .km-nav__link.active::before {
            width: 70%;
            opacity: 1;
        }

    /* Dropdown Submenu xổ xuống Desktop */
    .km-dropdown {
        display: block !important;
        position: absolute;
        top: calc(50% + (1em / 2) + 12px);
        left: 0;
        min-width: 220px;
        background: #ffffff;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        border-radius: 8px;
        padding: 8px 0;
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(8px);
        transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    }

        /* Cầu nối hover mượt */
        .km-dropdown::before {
            content: "";
            position: absolute;
            top: -16px;
            left: 0;
            width: 100%;
            height: 16px;
            background: transparent;
        }

        .km-nav__item:hover > .km-dropdown,
        .km-nav__item--dropdown:hover > .km-dropdown,
        .km-dropdown:hover {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transform: translateY(0);
        }

    .km-dropdown__item {
        color: #333333 !important; /* Chữ tối màu trên popup nền trắng */
        font-size: 0.75rem;
        transition: background 0.2s ease, color 0.2s ease;
    }

        .km-dropdown__item:hover {
            background: #f0f7ff;
            color: var(--km-green, #00aa5a) !important;
            text-decoration: none;
        }

        .km-dropdown__item.active {
            background: #fff8c8;
            color: #222222 !important;
            font-weight: 600;
        }
}
