/* ============================================================
   navbar.css - 现代化导航样式 (优化版)
   ============================================================ */

/* ============================================================
   基础重置
   ============================================================ */
.navbar * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================================
   顶部导航
   ============================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.navbar-scrolled {
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
}

.navbar-inner {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 0;
}

/* ============================================================
   Logo - 固定宽度，不伸缩
   ============================================================ */
.navbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    padding-right: 24px;
}

.navbar-logo svg {
    flex-shrink: 0;
    display: block;
}

.navbar-logo span {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f59e0b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 0.3px;
    line-height: 1;
}

/* ============================================================
   导航菜单 - 紧挨Logo，左对齐
   ============================================================ */
.navbar-menu {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    margin: 0;
    padding: 20px;
    flex: 1 1 auto;
    height: 100%;
}

.navbar-menu > li {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

/* ============================================================
   导航链接 - 优化文字和图标
   ============================================================ */
.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    background: transparent;
    border: none;
    cursor: pointer;
    height: 38px;
    line-height: 1;
    position: relative;
}

.nav-link i {
    font-size: 17px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    color: #9ca3af;
}

.nav-link:hover {
    color: #111827;
    background: rgba(243, 244, 246, 0.8);
}

.nav-link:hover i {
    color: #6366f1;
    transform: scale(1.05);
}

.nav-link.active {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.08);
    font-weight: 600;
}

.nav-link.active i {
    color: #4f46e5;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 2.5px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 2px;
}

/* ============================================================
   下拉菜单 - 桌面版
   ============================================================ */
.nav-dropdown {
    position: relative;
    height: 100%;
}

.nav-dropdown-toggle .nav-dropdown-arrow {
    font-size: 12px;
    margin-left: 2px;
    transition: transform 0.25s ease;
    color: #9ca3af;
}

.nav-dropdown:hover .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    min-width: 210px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(226, 232, 240, 0.6);
    padding: 8px 6px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    list-style: none;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.active-dropdown .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown-menu li {
    display: block;
}

.nav-dropdown-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.15s ease;
}

.nav-dropdown-menu li a i {
    font-size: 16px;
    color: #9ca3af;
    width: 20px;
    text-align: center;
    transition: color 0.15s ease;
}

.nav-dropdown-menu li a:hover {
    background: rgba(243, 244, 246, 0.8);
    color: #111827;
}

.nav-dropdown-menu li a:hover i {
    color: #6366f1;
}

.nav-dropdown-divider {
    height: 1px;
    background: rgba(226, 232, 240, 0.6);
    margin: 4px 10px;
}

/* ============================================================
   右侧区域
   ============================================================ */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    height: 100%;
}

/* ============================================================
   按钮
   ============================================================ */
.navbar-btn {
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    height: 36px;
    line-height: 1;
}

.navbar-btn i {
    font-size: 16px;
}

.navbar-btn-ghost {
    background: transparent;
    color: #4b5563;
}

.navbar-btn-ghost:hover {
    background: rgba(243, 244, 246, 0.8);
    color: #111827;
}

.navbar-btn-ghost i {
    color: #9ca3af;
}

.navbar-btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.navbar-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

/* ============================================================
   用户头像
   ============================================================ */
.user-dropdown-wrapper {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.user-avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 10px 3px 3px;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1.5px solid transparent;
    background: transparent;
    cursor: pointer;
    height: 36px;
}

.user-avatar-btn:hover {
    background: rgba(243, 244, 246, 0.8);
    border-color: rgba(226, 232, 240, 0.6);
}

.user-avatar-btn.open {
    background: rgba(243, 244, 246, 0.8);
    border-color: rgba(226, 232, 240, 0.6);
}

.user-avatar-img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar-name {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-avatar-arrow {
    font-size: 14px;
    color: #9ca3af;
    transition: transform 0.25s ease;
}

.user-avatar-btn.open .user-avatar-arrow {
    transform: rotate(180deg);
}

/* ============================================================
   用户下拉面板
   ============================================================ */
.user-dropdown-panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 220px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(226, 232, 240, 0.6);
    padding: 8px 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top right;
    z-index: 1000;
}

.user-dropdown-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.user-dropdown-header {
    padding: 8px 12px 12px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    margin-bottom: 4px;
}

.user-dropdown-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.user-dropdown-role {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.user-dropdown-divider {
    height: 1px;
    background: rgba(226, 232, 240, 0.6);
    margin: 4px 8px;
}

.user-dropdown-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.15s ease;
}

.user-dropdown-link:hover {
    background: rgba(243, 244, 246, 0.8);
    color: #111827;
}

.user-dropdown-link i {
    font-size: 16px;
    color: #9ca3af;
    width: 20px;
    text-align: center;
}

.user-dropdown-logout {
    color: #ef4444;
}

.user-dropdown-logout:hover {
    background: #fef2f2;
    color: #dc2626;
}

.user-dropdown-logout i {
    color: #ef4444;
}

/* ============================================================
   移动端菜单按钮
   ============================================================ */
.navbar-mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 4.5px;
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.navbar-mobile-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #1f2937;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.navbar-mobile-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(4.5px, 4.5px);
}

.navbar-mobile-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.navbar-mobile-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(4.5px, -4.5px);
}

/* ============================================================
   移动端底部导航
   ============================================================ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    justify-content: space-around;
    z-index: 1000;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    font-size: 10px;
    color: #9ca3af;
    text-decoration: none;
    transition: all 0.2s ease;
    min-width: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.mobile-nav-item i {
    font-size: 20px;
    color: #9ca3af;
    transition: color 0.2s ease;
}

.mobile-nav-item span {
    font-size: 10px;
    line-height: 1.1;
}

.mobile-nav-item.active {
    color: #4f46e5;
}

.mobile-nav-item.active i {
    color: #4f46e5;
}

.mobile-nav-item:hover {
    color: #4f46e5;
}

.mobile-nav-item:hover i {
    color: #4f46e5;
}

/* ============================================================
   响应式 - 移动端
   ============================================================ */
@media (max-width: 768px) {
    .navbar {
        padding: 0 12px;
        height: 54px;
    }

    .navbar-logo {
        padding-right: 0;
    }

    .navbar-logo span {
        font-size: 16px;
    }

    /* ===== 桌面菜单隐藏 ===== */
    .navbar-menu {
        position: fixed;
        top: 0px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 12px 16px 20px;
        gap: 2px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
        transform: translateY(-120%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 998;
        max-height: calc(100vh - 54px);
        overflow-y: auto;
        align-items: stretch;
        border-bottom: 1px solid rgba(226, 232, 240, 0.6);
        flex: none;
        width: 100%;
        height: auto;
    }

    .navbar-menu.open {
        transform: translateY(0);
    }

    .navbar-menu > li {
        display: block;
        height: auto;
    }

    /* ===== 移动端导航链接 ===== */
    .nav-link {
        padding: 10px 14px;
        font-size: 14px;
        width: 100%;
        border-radius: 8px;
        justify-content: flex-start;
        height: 44px;
        color: #4b5563;
    }

    .nav-link i {
        font-size: 18px;
        width: 24px;
        text-align: center;
    }

    .nav-link.active {
        background: rgba(79, 70, 229, 0.06);
        color: #4f46e5;
    }

    .nav-link.active::after {
        display: none;
    }

    .nav-link.active i {
        color: #4f46e5;
    }

    /* ===== 移动端下拉菜单 ===== */
    .nav-dropdown {
        display: block;
        height: auto;
    }

    .nav-dropdown-menu {
        position: static;
        transform: none !important;
        box-shadow: none;
        border: none;
        padding: 4px 0 4px 28px;
        opacity: 1 !important;
        visibility: visible !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: transparent;
        border-radius: 0;
        width: 100%;
    }

    .nav-dropdown.active-dropdown .nav-dropdown-menu {
        max-height: 500px;
        padding: 4px 0 4px 28px;
    }

    .nav-dropdown-toggle {
        justify-content: flex-start;
    }

    .nav-dropdown-toggle .nav-dropdown-arrow {
        margin-left: auto;
        font-size: 14px;
        transition: transform 0.3s ease;
    }

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

    .nav-dropdown-menu li a {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 6px;
        color: #6b7280;
    }

    .nav-dropdown-menu li a i {
        font-size: 15px;
        width: 20px;
    }

    .nav-dropdown-menu li a:hover {
        background: rgba(243, 244, 246, 0.6);
    }

    .nav-dropdown-divider {
        margin: 4px 8px;
    }

    /* ===== 移动端菜单按钮 ===== */
    .navbar-mobile-toggle {
        display: flex;
    }

    /* ===== 用户区域 ===== */
    .user-avatar-name {
        display: none;
    }

    .user-avatar-btn {
        padding: 2px 6px 2px 2px;
        height: 34px;
    }

    .user-avatar-img {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .user-avatar-arrow {
        font-size: 12px;
    }

    .navbar-btn {
        font-size: 12px;
        padding: 4px 10px;
        height: 32px;
    }

    .navbar-btn i {
        font-size: 14px;
    }

    /* ===== 底部导航显示 ===== */
    .mobile-bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: 56px;
    }
}

@media (max-width: 480px) {
    .navbar {
        height: 50px;
        padding: 0 10px;
    }

    .navbar-logo span {
        font-size: 14px;
    }

    .navbar-logo svg {
        width: 24px;
        height: 24px;
    }

    .navbar-menu {
        top: 0px;
        padding: 10px 12px 16px;
    }

    .nav-link {
        font-size: 13px;
        padding: 8px 12px;
        height: 40px;
    }

    .nav-link i {
        font-size: 16px;
        width: 22px;
    }

    .navbar-btn {
        font-size: 11px;
        padding: 3px 8px;
        height: 28px;
    }

    .navbar-btn i {
        font-size: 13px;
    }

    .user-avatar-btn {
        height: 28px;
        padding: 2px 4px 2px 2px;
    }

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

    .user-dropdown-panel {
        right: -8px;
        min-width: 180px;
    }

    .mobile-nav-item {
        font-size: 9px;
        min-width: 36px;
    }

    .mobile-nav-item i {
        font-size: 18px;
    }

    body {
        padding-bottom: 50px;
    }
}

/* ============================================================
   Safe Area 适配
   ============================================================ */
@supports (padding: max(0px)) {
    .mobile-bottom-nav {
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }

    .navbar-menu {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ============================================================
   滚动条美化
   ============================================================ */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}