/* Header & Navigation */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    gap: var(--space-4);
}

/* Brand */
.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    color: var(--black);
    font-weight: var(--font-bold);
    font-size: var(--text-lg);
    flex-shrink: 0;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 11px;
    font-weight: var(--font-bold);
}

.brand-logo {
    height: 28px;
    width: auto;
}

.brand-text {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--black);
}

/* Nav Links */
.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--gray-700);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--black);
    background: var(--gray-200);
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-lighter);
}

.nav-link .dropdown-arrow {
    font-size: 8px;
    transition: transform var(--transition-fast);
}

/* Dropdowns */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 220px;
    padding: var(--space-1);
    margin-top: var(--space-1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--transition-fast);
    z-index: 150;
}

.nav-item:hover .dropdown-menu,
.nav-item.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-family);
}

.dropdown-item:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: var(--text-xs);
    color: var(--gray-500);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-1) 0;
}

/* Nav Right */
.nav-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* User Menu (logged-in) */
.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    color: var(--gray-700);
    font-size: var(--text-sm);
    font-family: var(--font-family);
}

.user-btn:hover {
    background: var(--gray-200);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    gap: 1px;
}
.user-name {
    font-weight: var(--font-medium);
}
/* Level line under the name — borderless, blends with the name. */
.user-level {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: var(--font-semibold, 600);
    color: var(--primary, #2563EB);
}
.user-level-bar {
    width: 34px; height: 4px;
    background: var(--gray-200, #E5E7EB);
    border-radius: 999px;
    overflow: hidden;
}
.user-level-bar > span {
    display: block; height: 100%;
    background: var(--primary, #2563EB);
    border-radius: 999px;
}
@media (max-width: 640px) { .user-level { display: none; } }

.user-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 260px;
    padding: var(--space-1);
    display: none;
    z-index: 200;
    white-space: nowrap;
}

.user-dropdown.show {
    display: block;
}

.user-info {
    padding: var(--space-3);
}

.user-info strong {
    display: block;
    font-size: var(--text-sm);
    color: var(--black);
}

.user-email {
    font-size: var(--text-xs);
    color: var(--gray-500);
}

.logout-btn {
    color: var(--error) !important;
}

.logout-btn:hover {
    background: var(--error-light) !important;
    color: var(--error) !important;
}

/* Mobile Menu */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--gray-700);
    font-size: var(--text-lg);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius);
}

.mobile-menu-btn:hover {
    background: var(--gray-200);
}

.mobile-menu {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--white);
    z-index: 99;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}

.mobile-menu-title {
    font-weight: var(--font-semibold);
    color: var(--black);
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: var(--text-lg);
    cursor: pointer;
}

.mobile-menu-content {
    padding: var(--space-2);
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-family);
}

.mobile-menu-item:hover {
    background: var(--gray-200);
    color: var(--black);
}

.mobile-menu-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    padding: var(--space-3) var(--space-4) var(--space-1);
    margin-top: var(--space-2);
}
.mobile-menu-label:first-child { margin-top: 0; }

/* Breadcrumb */
.breadcrumb-section {
    background: var(--gray-100);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) 0;
    font-size: var(--text-xs);
    color: var(--gray-500);
}

.breadcrumb a {
    color: var(--gray-500);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-menu {
        display: block;
    }

    .nav {
        padding: 0 var(--space-4);
    }

    .brand-text {
        font-size: var(--text-base);
    }
}

/* ── User-avatar dropdown hover: theme-independent ──────────────────────────
   The menu items use fixed light-theme text (inline color:#374151). A generic
   `.dropdown-item:hover { background: var(--surface) }` turns dark in OS dark
   mode (--surface → #2d3748), hiding that text. Scope a readable light hover
   to the user dropdown so it never depends on the theme's --surface. */
.user-dropdown .dropdown-item:hover {
    background: #F3F4F6;
    color: #111827;
    transform: none;
}
.user-dropdown .dropdown-item:hover i { color: #2563EB; }
.user-dropdown .logout-btn:hover { background: #FEF2F2; color: #DC2626; }
.user-dropdown .logout-btn:hover i { color: #DC2626; }

/* ── Header nav dropdowns (Khóa học / Lộ trình / Công cụ): theme-independent ──
   These `.nav-item .dropdown-menu` menus are designed light (white bg, dark
   text) but inherit dark-mode --white/--surface/text vars in OS dark mode,
   producing a dark menu with a low-contrast hover. Lock them to a readable
   light palette with fixed hex, scoped high enough to win over the theme vars. */
.nav-item .dropdown-menu {
    background: #ffffff;
    border-color: #E5E7EB;
}
.nav-item .dropdown-menu .dropdown-item {
    color: #374151;
}
.nav-item .dropdown-menu .dropdown-item i {
    color: #6B7280;
}
.nav-item .dropdown-menu .dropdown-item:hover {
    background: #F3F4F6;
    color: #111827;
    transform: none;
}
.nav-item .dropdown-menu .dropdown-item:hover i {
    color: #2563EB;
}

/* ── Career level chip (shared .ce-chip) — header/landing ── */
.ce-chip { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 4px 10px; border: 1px solid var(--border, #E5E7EB); border-radius: 999px; background: #fff; margin-right: 10px; }
.ce-chip:hover { border-color: var(--primary, #2563EB); }
.ce-chip-lvl { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--primary, #2563EB); white-space: nowrap; }
.ce-chip-bar { width: 46px; height: 5px; background: #E5E7EB; border-radius: 999px; overflow: hidden; }
.ce-chip-bar-fill { display: block; height: 100%; background: var(--primary, #2563EB); border-radius: 999px; }
@media (max-width: 640px) { .ce-chip { display: none; } }
