/* =============================================================
   NAVBAR COMPONENT
   Single source of truth cho tất cả trang dùng header.html.
   Self-contained: defines own brand tokens, fallbacks for shared tokens.
   ============================================================= */

:root {
  /* Brand identity — purple, không phụ thuộc vào --primary-color của từng trang */
  --brand-color: #7c3aed;
  --brand-hover: #6d28d9;
}

/* Navigation Bar - sticky, backdrop blur */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: var(--shadow-sm, 0 1px 2px 0 rgb(0 0 0 / 0.05));
    width: 100%;
}

.navbar .container {
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
}

/* Brand / Logo — luôn dùng màu brand (tím), không phụ thuộc vào --primary-color của từng trang */
.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--brand-color) !important;
    text-decoration: none;
    margin-right: 0;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.navbar-brand:hover {
    color: var(--brand-hover) !important;
    opacity: 0.9;
}

/* Navigation Tabs */
.nav-tabs {
    border: none;
    gap: 0.25rem;
    margin-left: 0.75rem;
    flex-wrap: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.nav-tabs .nav-link {
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: #1a1a1a;
    transition: all 0.2s ease;
    background: transparent;
    position: relative;
    text-decoration: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.nav-tabs .nav-link:hover {
    background: rgba(124, 58, 237, 0.08);
    color: var(--brand-color);
}

.nav-tabs .nav-link.active {
    background: linear-gradient(135deg, var(--brand-color) 0%, var(--brand-hover) 100%);
    color: white;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
}

/* Dropdown arrow indicator */
.nav-dropdown .nav-link::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: 0.4rem;
    transition: transform 0.3s ease;
    font-size: 0.75em;
}

.nav-dropdown.active .nav-link::after {
    transform: rotate(180deg);
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
}

/* Cầu nối vô hình để không mất hover khi di chuột từ nav vào menu */
.nav-dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
    z-index: 1043;
    pointer-events: auto;
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.1));
    border: 1px solid var(--border-color, #e5e7eb);
    z-index: 1042;
    min-width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    /* overflow: hidden bị xóa — nó clip mất .nav-submenu là position:absolute left:100% */
}

.nav-dropdown.active .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.nav-dropdown-item {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--dark-color, #1e293b);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
}

.nav-dropdown-item:last-child {
    border-bottom: none;
}

.nav-dropdown-item.active {
    background: rgba(124, 58, 237, 0.1);
    color: var(--brand-color);
    font-weight: 600;
}

.nav-dropdown-item:hover {
    background: rgba(124, 58, 237, 0.06);
    color: var(--brand-color);
}

.nav-dropdown-item i {
    width: 18px;
    font-size: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-dropdown-item span {
    white-space: nowrap;
}

/* Submenu */
.has-submenu {
    position: relative;
    cursor: pointer;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 11px;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.has-submenu:hover .submenu-arrow {
    transform: rotate(90deg);
    opacity: 1;
}

.nav-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.1));
    border: 1px solid var(--border-color, #e5e7eb);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1043;
    pointer-events: none;
    overflow: hidden;
}

.has-submenu:hover .nav-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

.nav-submenu-item {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--dark-color, #1e293b);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
}

.nav-submenu-item:last-child {
    border-bottom: none;
}

.nav-submenu-item.active {
    background: rgba(124, 58, 237, 0.1);
    color: var(--brand-color);
    font-weight: 600;
}

.nav-submenu-item:hover {
    background: rgba(124, 58, 237, 0.06);
    color: var(--brand-color);
    box-shadow: inset 3px 0 0 var(--brand-color);
}

.nav-submenu-item i {
    width: 18px;
    font-size: 1rem;
    text-align: center;
    flex-shrink: 0;
}

/* Search box */
.nav-search-container {
    flex-shrink: 0;
    margin: 0 0.5rem;
}

.nav-search-box {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 25px;
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 0.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nav-search-box:focus-within {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.nav-search-input {
    border: none;
    background: transparent;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
    width: 160px;
    color: var(--text-primary, #111827);
}

.nav-search-btn {
    background: linear-gradient(135deg, var(--brand-color) 0%, var(--brand-hover) 100%);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.nav-search-btn:hover {
    opacity: 0.85;
}

.nav-search-suggestions {
    position: absolute;
    top: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.1));
    border: 1px solid var(--border-color, #e5e7eb);
    min-width: 260px;
    z-index: 1050;
    margin-top: 4px;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
    margin-left: 10px;
    flex-shrink: 0;
}

.user-dropdown-btn {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    padding: 7px 14px 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    min-width: 130px;
    justify-content: flex-start;
    position: relative;
}

.user-dropdown-btn:hover {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Avatar */
.user-avatar-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.user-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e2e8f0;
}

.user-avatar-icon {
    font-size: 26px;
    color: #94a3b8;
    line-height: 1;
}

.user-btn-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
    line-height: 1.2;
}

/* Rank Insignia */
.rank-insignia {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 16px;
}

.epaulette {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    background: #A11212;
    border-radius: 3px;
    padding: 1px 4px;
    line-height: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 2px rgba(0, 0, 0, 0.25);
}

.ep-star {
    font-size: 8px;
    color: #F4C430;
    line-height: 1;
    text-shadow: 0 0 3px rgba(244, 196, 48, 0.8), 0 1px 1px rgba(0, 0, 0, 0.4);
}

.ep-chevron {
    font-size: 11px;
    font-weight: 700;
    color: #F4C430;
    line-height: 1;
    letter-spacing: -1px;
    text-shadow: 0 0 3px rgba(244, 196, 48, 0.8), 0 1px 1px rgba(0, 0, 0, 0.4);
}

.ribbon-bar {
    display: inline-flex;
    align-items: center;
    border-radius: 2px;
    overflow: hidden;
    height: 8px;
    gap: 1px;
    padding: 0 1px;
    background: rgba(0, 0, 0, 0.08);
}

.ribbon-seg {
    display: inline-block;
    width: 8px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 1px;
    background: #64748B;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.ribbon-vsa_student   { background: #7C3AED; }
.ribbon-macro_student { background: #2563EB; }
.ribbon-gann_student  { background: #F59E0B; }
.ribbon-fund_student  { background: #10B981; }
.ribbon-customer      { background: #22C55E; }

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.user-dropdown.show .dropdown-arrow {
    transform: rotate(180deg);
}

/* User dropdown menu */
.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1042;
    margin-top: 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #e9ecef;
}

.user-dropdown-header i {
    font-size: 18px;
    color: var(--brand-color);
}

.user-dropdown-header span {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.user-dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 0;
}

.user-dropdown-item {
    padding: 15px 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s ease;
    font-size: 15px;
    color: #495057;
    border-bottom: 1px solid #f8f9fa;
    text-decoration: none;
    font-weight: 500;
}

.user-dropdown-item:hover {
    background: #f5f3ff;
    color: var(--brand-color);
    transform: translateX(4px);
}

.user-dropdown-item.login-btn:hover {
    background: #16a34a;
    color: white;
}

.user-dropdown-item.register-btn:hover {
    background: var(--brand-color);
    color: white;
}

.user-dropdown-item i {
    font-size: 17px;
    color: #6c757d;
    transition: color 0.2s ease;
    width: 18px;
    text-align: center;
}

.user-dropdown-item:hover i {
    color: inherit;
}

/* Mobile hamburger toggle */
.mobile-menu-toggle {
    display: none;
    background: linear-gradient(135deg, var(--brand-color) 0%, var(--brand-hover) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: var(--shadow-sm, 0 1px 2px 0 rgb(0 0 0 / 0.05));
    margin-right: 12px;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.mobile-menu-toggle i {
    font-size: 1.2rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .nav-tabs {
        display: none !important;
    }

    .navbar-brand {
        font-size: 1.4rem;
    }

    .user-dropdown {
        margin-left: auto;
    }

    .navbar .container {
        padding: 0 1rem;
        max-width: 100%;
    }

    .user-dropdown-btn {
        min-width: 110px;
        padding: 6px 12px 6px 7px;
        font-size: 13px;
    }

    .nav-search-container {
        display: none;
    }
}

@media (max-width: 576px) {
    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
    }

    .mobile-menu-toggle i {
        font-size: 1.1rem;
    }

    .navbar-brand {
        font-size: 1.25rem;
    }

    .user-dropdown-btn {
        min-width: 90px;
        padding: 5px 10px 5px 6px;
        font-size: 12px;
    }

    .user-name {
        max-width: 60px;
    }

    .user-avatar-img {
        width: 24px;
        height: 24px;
    }

    .user-avatar-icon {
        font-size: 22px;
    }

    .ribbon-seg {
        width: 6px;
    }

    .ep-star {
        font-size: 7px;
    }
}

@media (max-width: 480px) {
    .mobile-menu-toggle {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 992px) {
    .navbar .container {
        max-width: 960px;
    }
}

@media (min-width: 1400px) {
    .navbar .container {
        max-width: 1400px;
    }

    .nav-tabs .nav-link {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}
