/* =========================================
   HEADER COMPONENT
   ========================================= */
.nomad-header {
    background-color: var(--color-white, #F7F8F6);
    border-bottom: 1px solid var(--color-silver, #DDE1E5);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: box-shadow 0.2s ease-in-out;
}

.nomad-header--scrolled {
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.nomad-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
}

.nomad-header__logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--color-text, #151719);
}

/* --- FIX CHO DESKTOP: ÉP DÀN NGANG --- */
.nomad-header__nav {
    display: flex;
    align-items: center;
    flex: 1; /* Cho phép nav chiếm hết không gian còn lại */
}

/* Đẩy menu ra giữa */
.nomad-header__menu {
    display: flex;
    gap: 32px;
    margin: 0 auto; /* Tự động căn giữa không gian */
}

.nomad-header__menu-link {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text, #151719);
    transition: color 0.2s ease-in-out;
}

.nomad-header__menu-link:hover,
.nomad-header__menu-link:focus {
    color: var(--color-orange, #FF4D2E);
}

/* Cụm Action nằm sát bên phải */
.nomad-header__actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nomad-header__action-btn, 
.nomad-header__lang-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text, #151719);
    padding: 0;
}

/* Ẩn các nút của Mobile trên Desktop */
.nomad-header__mobile-toggle,
.nomad-header__close-btn,
.nomad-header__nav-top,
.nomad-header__overlay {
    display: none;
}


/* =========================================
   MOBILE RESPONSIVE (OFF-CANVAS)
   ========================================= */
@media (max-width: 1024px) {
    .nomad-header__nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 300px;
        height: 100vh;
        background: var(--color-white, #fff);
        z-index: 1002;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        transition: right 0.3s ease-in-out;
        overflow-y: auto;
    }

    .nomad-header__nav.is-active {
        right: 0;
    }

    .nomad-header__menu {
        flex-direction: column;
        gap: 0;
        width: 100%;
        margin: 0; /* Reset margin auto trên mobile */
    }

    .nomad-header__menu-link {
        display: block;
        padding: 16px 24px;
        border-bottom: 1px solid var(--color-silver, #eee);
        font-size: 16px;
    }

    .nomad-header__actions {
        flex-direction: column;
        align-items: flex-start;
        padding: 24px;
        gap: 24px;
        width: 100%;
    }

    .nomad-header__nav-top {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        padding: 20px 24px;
        border-bottom: 1px solid var(--color-silver, #eee);
    }

    .nomad-header__close-btn {
        display: block;
        background: none;
        border: none;
        font-size: 28px;
        cursor: pointer;
        line-height: 1;
        color: var(--color-text);
    }
    
    .nomad-header__mobile-toggle {
        display: block;
        background: none;
        border: none;
        padding: 8px;
        cursor: pointer;
    }

    .nomad-header__hamburger {
        display: block;
        width: 24px;
        height: 2px;
        background: var(--color-text, #000);
        position: relative;
    }

    .nomad-header__hamburger::before,
    .nomad-header__hamburger::after {
        content: '';
        position: absolute;
        width: 24px;
        height: 2px;
        background: var(--color-text, #000);
        left: 0;
    }
    .nomad-header__hamburger::before { top: -6px; }
    .nomad-header__hamburger::after { bottom: -6px; }

    .nomad-header__overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0, 0.5);
        z-index: 1001;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out;
    }

    .nomad-header__overlay.is-active {
        display: block;
        opacity: 1;
        visibility: visible;
    }
}

/* =========================================
   TỐI ƯU MENU HEADER & MOBILE NAVIGATION (OFF-CANVAS)
   ========================================= */
@media (max-width: 768px) {
    /* 1. Thanh Header chung cố định */
    html body .nomad-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 10000 !important;
        background: #FFFFFF !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    html body .nomad-header__inner {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 12px 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 2. Nút Hamburger (Toggle Menu Mobile) */
    html body .nomad-header__mobile-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        padding: 8px !important;
        z-index: 1001 !important;
    }

    /* 3. Khung Menu trượt (Off-Canvas Navigation Drawer) */
    html body .nomad-header__nav {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important; /* Mặc định ẩn sang bên phải màn hình */
        width: 85% !important;
        max-width: 360px !important;
        height: 100vh !important;
        background: #FFFFFF !important;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15) !important;
        transition: right 0.35s ease-in-out !important;
        z-index: 10002 !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
        padding: 24px !important;
    }

    /* Khi kích hoạt mở menu (Thêm class .is-active hoặc logic JS của bro) */
    html body .nomad-header__nav.is-active,
    html body .nomad-header__nav[aria-hidden="false"] {
        right: 0 !important;
    }

    /* 4. Thanh Top bên trong Menu (Logo phụ & Nút đóng X) */
    html body .nomad-header__nav-top {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 24px !important;
        padding-bottom: 16px !important;
        border-bottom: 1px solid #E5E7EB !important;
        width: 100% !important;
    }

    html body .nomad-header__close-btn {
        background: transparent !important;
        border: none !important;
        font-size: 28px !important;
        cursor: pointer !important;
        color: #101214 !important;
        line-height: 1 !important;
        padding: 4px 8px !important;
    }

    /* 5. Danh sách các liên kết trong Menu */
    html body .nomad-header__menu {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        list-style: none !important;
        padding: 0 !important;
        margin: 0 0 24px 0 !important;
        width: 100% !important;
    }

    html body .nomad-header__menu-item {
        width: 100% !important;
    }

    html body .nomad-header__menu-link {
        font-size: 16px !important;
        font-weight: 600 !important;
        color: #101214 !important;
        text-decoration: none !important;
        display: block !important;
        padding: 8px 0 !important;
        transition: color 0.2s ease !important;
    }

    html body .nomad-header__menu-link:hover {
        color: #FF4D2E !important;
    }

    /* 6. Các nút hành động bên dưới Menu (Tìm kiếm, Ngôn ngữ, Tài khoản, CTA) */
    html body .nomad-header__actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        margin-top: auto !important; /* Đẩy xuống đáy khung menu nếu còn trống */
        padding-top: 20px !important;
        border-top: 1px solid #E5E7EB !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    html body .nomad-header__action-btn {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        background: #F5F7F9 !important;
        border: none !important;
        border-radius: 8px !important;
        padding: 12px 16px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        text-align: left !important;
        width: 100% !important;
    }

    html body .nomad-header__cta {
        width: 100% !important;
        text-align: center !important;
        box-sizing: border-box !important;
        display: inline-flex !important;
        justify-content: center !important;
        margin-top: 8px !important;
    }

    /* 7. Lớp phủ nền tối (Overlay) khi bật menu */
    html body .nomad-header__overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.5) !important;
        backdrop-filter: blur(3px) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: all 0.35s ease-in-out !important;
        z-index: 10001 !important;
    }

    html body .nomad-header__overlay.is-active,
    html body .nomad-header__overlay[aria-hidden="false"] {
        opacity: 1 !important;
        visibility: visible !important;
    }
}