/* ========================================
   清远市制造业赋能服务平台 - 头部导航栏样式
   从 main.css 抽离，便于统一维护
   ======================================== */

/* ========== 顶部导航栏 ========== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    transition: all var(--transition-normal);
}

.header.scrolled {
    box-shadow: var(--shadow-md);
}

.header-container {
    display: flex;
    align-items: center;
    height: 70px;
    max-width: 98%;
    margin: 0 auto;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.main-nav {
    justify-self: center;
}

.header-actions {
    justify-self: end;
}

.logo-icon {
    height: 60px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

.logo-img {
    max-height: 100%;
    width: auto;
    object-fit: contain;
}

/* 移动端菜单按钮 - 桌面端隐藏 */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1100;
    position: relative;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s;
    border-radius: 1px;
}

.mobile-menu-btn:hover span {
    background: var(--primary-color);
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.logo-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-light);
    letter-spacing: 0.5px;
}

.main-nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.nav-item {
    position: relative;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: var(--spacing-md);
    right: var(--spacing-md);
    height: 2px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

/* 下拉菜单 */
.nav-item.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    padding: var(--spacing-sm) 0;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-normal);
}

.nav-item.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: block;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.dropdown-menu a:hover {
    background: var(--primary-bg);
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.btn-search {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.btn-search:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.btn-search svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--gradient-primary);
    color: white;
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-primary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -8px rgba(26, 86, 219, 0.5);
}

.btn-secondary {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: transparent;
    color: var(--primary-color);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

/* ========== 用户下拉菜单 ========== */
.user-dropdown {
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: rgba(26, 86, 219, 0.05);
    border: 1px solid rgba(26, 86, 219, 0.15);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-info:hover {
    background: rgba(26, 86, 219, 0.1);
    border-color: rgba(26, 86, 219, 0.3);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.user-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border-light);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.active .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.15s ease;
    text-decoration: none;
}

.dropdown-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.dropdown-item:hover svg {
    opacity: 1;
}

.dropdown-item .badge {
    margin-left: auto;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}

.dropdown-item .badge.new {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.dropdown-item .badge.pending {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.dropdown-item .badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 8px 0;
}

.dropdown-item.logout {
    color: #ef4444;
}

.dropdown-item.logout:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}

/* ========== 移动端菜单按钮（重复定义覆盖） ========== */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    width: 24px;
    height: 20px;
    background: transparent;
}

.mobile-menu-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    transition: all var(--transition-fast);
}

/* ========== 响应式 - 平板端 (992px) ========== */
@media (max-width: 992px) {
    /* ========== 侧边栏导航 ========== */
    .main-nav {
        position: fixed !important;
        top: 0;
        left: auto !important;
        right: -280px;
        transform: none !important;
        width: 280px;
        height: 100vh;
        height: 100dvh;
        background: #fff;
        flex-direction: column;
        padding: 0;
        margin: 0;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
        gap: 0;
        z-index: 1001 !important;
        overflow-y: auto;
        overflow-x: hidden;
        transition: right 0.3s ease;
        display: flex !important;
    }

    .main-nav.active {
        right: 0;
    }

    .main-nav::before {
        display: none;
    }

    /* 侧边栏头部 */
    .nav-header {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: #f9fafb;
        border-bottom: 1px solid #e5e7eb;
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .nav-header-title {
        font-size: 16px;
        font-weight: 600;
        color: #1f2937;
    }

    .nav-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: transparent;
        border: none;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s;
    }

    .nav-close-btn:hover {
        background: #e5e7eb;
    }

    .nav-close-btn svg {
        width: 20px;
        height: 20px;
        color: #6b7280;
    }

    .nav-close-btn:hover svg {
        color: #1f2937;
    }

    /* 导航项样式 */
    .nav-item {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
        border-bottom: 1px solid #f3f4f6;
        text-decoration: none;
    }

    .nav-item:last-child {
        border-bottom: none;
    }

    .nav-item > span {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        font-size: 15px;
        color: #374151;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        line-height: 1.5;
    }

    a.nav-item {
        display: flex;
        align-items: center;
        padding: 16px 20px;
        font-size: 15px;
        color: #374151;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        line-height: 1.5;
    }

    .nav-item > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        font-size: 15px;
        color: #374151;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        text-decoration: none;
        line-height: 1.5;
    }

    .nav-item > span:hover,
    .nav-item > a:hover,
    a.nav-item:hover {
        background: #f3f4f6;
        color: var(--primary-color);
    }

    .nav-item.active > span,
    .nav-item.active > a,
    a.nav-item.active {
        color: var(--primary-color);
        background: rgba(26, 86, 219, 0.08);
    }

    /* 下拉箭头 */
    .nav-item.dropdown > span::after {
        content: '';
        width: 8px;
        height: 8px;
        border-right: 2px solid #9ca3af;
        border-bottom: 2px solid #9ca3af;
        transform: rotate(45deg);
        transition: transform 0.3s;
        flex-shrink: 0;
    }

    .nav-item.dropdown.active > span::after {
        transform: rotate(-135deg);
        border-color: var(--primary-color);
    }

    /* 二级菜单容器 */
    .nav-item.dropdown .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        background: #f9fafb;
        transition: max-height 0.3s ease;
    }

    .nav-item.dropdown.active .dropdown-menu {
        max-height: 400px;
        border-radius: 0;
    }

    /* 二级菜单链接 */
    .dropdown-menu a {
        display: block;
        padding: 14px 20px 14px 40px;
        font-size: 14px;
        color: #6b7280;
        font-weight: 400;
        text-decoration: none;
        line-height: 1.5;
        border-top: 1px solid #e5e7eb;
        transition: all 0.2s;
    }

    .dropdown-menu a:first-child {
        border-top: none;
    }

    .dropdown-menu a:hover {
        background: #f3f4f6;
        color: var(--primary-color);
        padding-left: 44px;
    }

    .dropdown-menu a.active {
        color: var(--primary-color);
        font-weight: 500;
        background: rgba(26, 86, 219, 0.08);
    }

    .mobile-menu-btn {
        display: flex !important;
    }
}

/* ========== 响应式 - 移动端 (768px) ========== */
@media (max-width: 768px) {
    /* Header层级调整 */
    .header {
        z-index: 900;
    }

    /* 移动端菜单按钮 */
    .mobile-menu-btn {
        display: flex !important;
        width: 44px;
        height: 44px;
        min-width: 44px;
        justify-content: center;
        align-items: center;
        gap: 5px;
        padding: 10px;
        background: transparent;
        border: none;
        cursor: pointer;
        z-index: 1100;
        position: relative;
    }

    .mobile-menu-btn span {
        display: block;
        width: 22px;
        height: 2px;
        background: #1f2937;
        transition: all 0.3s;
        border-radius: 1px;
    }

    .mobile-menu-btn:hover span {
        background: var(--primary-color);
    }

    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* 隐藏发布需求按钮，登录按钮由JS控制显示 */
    .header-actions .btn-primary {
        display: none !important;
    }

    /* 移动端登录按钮 */
    .header-actions .btn-secondary {
        display: inline-flex;
        padding: 8px 16px;
        font-size: 13px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 20px;
    }

    .header-actions .btn-secondary:hover {
        background: var(--primary-hover, #1e40af);
    }

    /* 遮罩层 */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 900;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Header布局调整 */
    .header-container {
        padding: 0;
    }

    .logo-link {
        gap: 8px;
    }

    .logo-img {
        height: 45px;
    }

    .logo-title {
        font-size: 14px;
    }

    .header-actions {
        gap: 8px;
        flex: 1;
        justify-content: flex-end;
    }

    /* 用户下拉菜单移动端适配 */
    .user-dropdown {
        z-index: 1001;
    }

    .user-dropdown .user-info {
        padding: 6px;
        gap: 6px;
    }

    .user-dropdown .user-name {
        font-size: 12px;
        max-width: 70px;
    }

    .user-dropdown .user-dropdown-menu {
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-width: unset !important;
        border-radius: 16px 16px 0 0;
        z-index: 9999 !important;
        max-height: 70vh;
        overflow-y: auto;
        padding: 16px;
        display: none !important;
    }

    .user-dropdown.active .user-dropdown-menu {
        display: block !important;
        visibility: visible !important;
        border-radius: 0;
    }

    .user-dropdown .dropdown-item {
        padding: 14px 16px;
        font-size: 15px;
    }

    .user-dropdown .dropdown-divider {
        margin: 8px 0;
    }
}

/* ========== 响应式 - 小屏 (480px) ========== */
@media (max-width: 480px) {
    .logo-title {
        font-size: 12px;
    }
}
