/* --- DARK MODE & LANGUAGE SWITCHER BUTTONS IN HEADER --- */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

#toggle-dark-mode {
    background: none;
    border: none;
    color: var(--primary, var(--primary));
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

#toggle-dark-mode:hover {
    background: rgba(0, 123, 255, 0.08);
    color: #0056b3;
}

#toggle-dark-mode .fa-moon {
    transition: transform 0.2s;
}

#toggle-dark-mode:active .fa-moon {
    transform: rotate(-20deg) scale(1.1);
}

#lang-switcher {
    background: var(--card-bg, #f8f9fa);
    color: var(--text, #222);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 1rem;
    outline: none;
    transition: border 0.2s, background 0.2s;
    margin-left: 0;
}

#lang-switcher:focus {
    border-color: var(--primary, var(--primary));
    background: #eaf4ff;
}

@media (max-width: 600px) {
    #lang-switcher {
        font-size: 0.95rem;
        padding: 5px 8px;
    }

    #toggle-dark-mode {
        font-size: 1.1rem;
        padding: 6px 7px;
    }
}

/* === HEADER V3 === */
.top-navigation {
    background-color: hsla(0, 0%, 100%, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 1000;
    transition: height 0.3s ease, box-shadow 0.3s ease;
}

/* Shrink-on-Scroll State */
.top-navigation.scrolled {
    height: 56px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.top-navigation.scrolled #navbarLogo {
    height: 28px;
}

.top-navigation.scrolled .navbar-menu a {
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
}

.top-navigation.scrolled .user-auth-section #userAvatar,
.top-navigation.scrolled .user-avatar {
    width: 32px;
    height: 32px;
}

.top-navigation.scrolled #searchInput {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.top-navigation.scrolled .user-info-box {
    padding: 0.3rem 0.75rem;
}

.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

#navbarLogo {
    height: 38px;
    width: auto;
    transition: height 0.3s ease;
}

.navbar-menu ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: var(--space-unit);
}

.navbar-menu a {
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-hard);
}

.navbar-menu a:hover {
    color: var(--color-text-primary);
    background-color: hsla(215, 28%, 17%, 0.05);
}

.navbar-menu a.active {
    color: var(--color-primary);
    font-weight: 700;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: calc(var(--space-unit) * 1.25);
}

/* Search Bar */
.search-container {
    display: flex;
    align-items: center;
}

#searchInput {
    background-color: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-right: none;
    border-radius: var(--border-radius-hard) 0 0 var(--border-radius-hard);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    outline-offset: 2px;
}

#searchButton {
    background-color: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-left: none;
    color: var(--color-text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: 0 var(--border-radius-hard) var(--border-radius-hard) 0;
    cursor: pointer;
}

#searchInput:focus {
    outline: 2px solid var(--color-primary);
    z-index: 1;
}

/* User Auth */
.user-auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-auth-section #userAvatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--color-surface);
    box-shadow: 0 0 0 1px var(--color-border);
}

.user-auth-section #userName {
    font-weight: 600;
}

a.user-profile-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: var(--border-radius-hard);
    padding: 0.25rem;
}

a.user-profile-link:hover {
    background-color: hsla(215, 28%, 17%, 0.05);
}

/* Mobile */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-primary);
    cursor: pointer;
}

/* --- Progressive Responsive Header --- */

/* 1500px: Compact menu spacing */
@media (max-width: 1500px) {
    .navbar-menu a {
        font-size: 0.85rem;
        padding: 0.35rem 0.45rem;
    }

    .navbar-menu ul {
        gap: 0.15rem;
    }

    #navbarLogo {
        height: 30px;
    }

    .navbar-right {
        gap: 0.75rem;
    }
}

/* 1300px: Hide search bar + user name, keep only avatar + logout */
@media (max-width: 1300px) {
    .search-container {
        display: none;
    }

    .user-auth-section #userName,
    .user-details .user-name,
    .user-details .user-email {
        display: none;
    }

    .user-info-box {
        padding: 0.3rem;
    }

    .navbar-menu a {
        font-size: 0.8rem;
        padding: 0.3rem 0.35rem;
    }
}

/* 1024px: Full mobile hamburger */
@media (max-width: 1024px) {

    .navbar-menu,
    .search-container {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }
}

/* === Mobile Menu: Premium Dark Sidebar === */

/* Backdrop overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(8, 12, 24, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Close button */
.close-mobile-menu {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: hsla(220, 60%, 60%, 0.15);
    border: 1px solid hsla(220, 60%, 60%, 0.2);
    color: #a0b4d0;
    font-size: 1.5rem;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.25s ease;
    z-index: 2;
}

.close-mobile-menu:hover {
    background: hsla(220, 60%, 60%, 0.3);
    color: #fff;
    transform: rotate(90deg);
}

/* Sidebar panel */
.mobile-menu-content {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100%;
    background: linear-gradient(180deg, #1a2038 0%, #141928 50%, #0f1320 100%);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 1101;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-overlay.is-open .mobile-menu-content {
    transform: translateX(0);
}

/* --- Branded Header in Sidebar --- */
.mobile-menu-content::before {
    content: '✦ HNP Education';
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1.25rem;
    background: linear-gradient(135deg, #1e2a4a 0%, #253560 100%);
    border-bottom: 1px solid hsla(220, 60%, 50%, 0.15);
    color: white;
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    position: relative;
}

.mobile-menu-content::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4361ee, #7c3aed, #f0a040);
    z-index: 3;
}

/* Navigation links */
#mobile-nav-links {
    padding: 0.75rem 0.75rem;
    flex-grow: 1;
    border-bottom: none;
    margin-bottom: 0;
}

#mobile-nav-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#mobile-nav-links li {
    margin-bottom: 0;
}

#mobile-nav-links a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: #a0aec0;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.7rem 0.85rem;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.25s ease;
    position: relative;
}

#mobile-nav-links a i {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: hsla(230, 60%, 55%, 0.12);
    border: 1px solid hsla(230, 60%, 55%, 0.15);
    color: #6c83ee;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

#mobile-nav-links a span {
    flex-grow: 1;
    letter-spacing: 0.02em;
}

#mobile-nav-links a:hover {
    background: hsla(220, 60%, 55%, 0.08);
    color: #e2e8f0;
}

#mobile-nav-links a:hover i {
    background: hsla(230, 60%, 55%, 0.25);
    color: #8da0f0;
    border-color: hsla(230, 60%, 55%, 0.35);
    transform: scale(1.05);
}

#mobile-nav-links a.active {
    background: hsla(230, 65%, 55%, 0.12);
    color: #fff;
    box-shadow: 0 0 20px hsla(230, 60%, 50%, 0.08);
}

#mobile-nav-links a.active i {
    background: linear-gradient(135deg, #4361ee, #6c83ee);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 10px hsla(230, 70%, 55%, 0.3);
}

/* --- User Card at Bottom --- */
#mobile-auth-section {
    margin-top: auto;
    padding: 0.75rem;
    flex-shrink: 0;
}

#mobile-auth-section .user-info-box,
#mobile-auth-section .user-auth-section,
#mobile-auth-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#mobile-auth-section>* {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    background: hsla(220, 40%, 25%, 0.5);
    border: 1px solid hsla(220, 50%, 45%, 0.15);
    border-radius: 14px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

#mobile-auth-section #userAvatar,
#mobile-auth-section .user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid hsla(220, 60%, 55%, 0.4);
    flex-shrink: 0;
}

#mobile-auth-section #userName,
#mobile-auth-section .user-name {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    flex-grow: 1;
    line-height: 1.3;
}

#mobile-auth-section #logoutButton,
#mobile-auth-section .logout-btn,
#mobile-auth-section .button {
    background: hsla(0, 70%, 55%, 0.15);
    border: 1px solid hsla(0, 60%, 50%, 0.2);
    color: #f87171;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

#mobile-auth-section #logoutButton:hover,
#mobile-auth-section .logout-btn:hover,
#mobile-auth-section .button:hover {
    background: hsla(0, 70%, 55%, 0.25);
    border-color: hsla(0, 60%, 50%, 0.35);
    color: #fca5a5;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px hsla(0, 70%, 50%, 0.2);
}


/* --- Responsive Rules (hamburger menu) --- */
@media (max-width: 1024px) {

    /* Hide desktop navigation and login button */
    .navbar-menu,
    .navbar-right {
        display: none;
    }

    /* Show hamburger menu icon */
    .mobile-menu-toggle {
        display: block;
        background: none;
        border: none;
        font-size: 1.8rem;
        color: var(--color-text-primary);
        cursor: pointer;
        position: relative;
        z-index: 1002;
        padding: 10px;
    }
}

/* Thay thế toàn bộ rule cũ cho a#loginButton bằng rule này */
.user-auth-section a#loginButton {
    display: inline-flex;
    /* Dùng inline-flex để nút không chiếm toàn bộ chiều rộng */
    align-items: center;
    /* <<< DÒNG NÀY SẼ CĂN GIỮA ICON VÀ CHỮ */
    justify-content: center;

    /* Các style cũ của bạn */
    padding: 8px 18px;
    font-size: 0.85em;
    white-space: nowrap;
    border-radius: 999px;
    /* Thêm bo tròn cho đồng bộ */
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-subtle);
}

.user-auth-section a#loginButton:hover {
    background-color: var(--color-surface-soft);
    border-color: #d1d1d7;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Giữ nguyên hoặc thêm mới rule này cho icon */
.user-auth-section a#loginButton i {
    margin-right: 8px;
    /* Khoảng cách giữa icon và chữ */
    font-size: 1.2em;
    /* Kích thước icon */
}




/* --- NEW STYLES FROM CODE CHANGE SUGGESTION --- */
.user-info-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    border-radius: 2rem;
    box-shadow: 0 2px 12px rgba(30, 42, 80, 0.08);
    padding: 0.5rem 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #2e7dff;
    background: #f7f9fb;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-name {
    font-weight: 600;
    color: #222;
}

.user-email {
    font-size: 0.9em;
    color: #888;
}

.cta-button.login-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    color: #222;
    border: 1px solid #e0e0e0;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
    box-shadow: 0 2px 12px rgba(30, 42, 80, 0.08);
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.cta-button.login-btn:hover {
    background: #f7f9fb;
    color: #2e7dff;
    box-shadow: 0 4px 16px rgba(30, 42, 80, 0.12);
}

.google-icon {
    width: 24px;
    height: 24px;
}

.logout-btn {
    background: #f7f9fb;
    color: #e53935;
    border: none;
    border-radius: 2rem;
    padding: 0.4rem 1.2rem;
    margin-left: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.logout-btn:hover {
    background: #ffeaea;
    color: #b71c1c;
}