/* 头部导航专用样式 - 防止与其他样式冲突 */
.header-nav * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.header-nav {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow-x: hidden;
}

/* 导航栏核心 - 强制防溢出 */
.header-nav #navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100vw;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow: visible !important;
}

.header-nav .nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: relative;
}

.header-nav .logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #333;
}

.header-nav .logo img {
    height: 40px;
    width: auto;
}

.header-nav .logo-text {
    margin-left: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    color: #3b82f6;
}

/* 移动端默认样式 */
.header-nav .desktop-nav, 
.header-nav .control-panel {
    display: none !important;
}

.header-nav .mobile-menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #374151;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1002;
}

.header-nav .mobile-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: white;
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    padding: 70px 1rem 2rem;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

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

.header-nav .mobile-nav-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-nav .mobile-nav-item {
    text-decoration: none;
    color: #374151;
    font-weight: 500;
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.header-nav .mobile-submenu {
    display: none;
    padding-left: 1rem;
    border-left: 2px solid #3b82f6;
    margin-left: 1rem;
    margin-bottom: 1rem;
}

.header-nav .mobile-submenu.active {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-nav .mobile-submenu-item {
    text-decoration: none;
    color: #64748b;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.header-nav .mobile-submenu-item:hover {
    background: #f0f9ff;
    color: #3b82f6;
}

.header-nav .mobile-control-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    border: 2px solid #3b82f6;
    border-radius: 0.375rem;
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.header-nav .overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.header-nav .overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 桌面端样式 */
@media (min-width: 768px) {
    .header-nav .desktop-nav {
        display: flex !important;
        align-items: center;
        gap: 2rem;
        position: static;
    }
    
    .header-nav .mobile-menu-btn {
        display: none !important;
    }
    
    .header-nav .control-panel {
        display: block !important;
    }
    
    .header-nav .nav-item {
        text-decoration: none;
        color: #374151;
        font-weight: 500;
        padding: 0.5rem 0;
        position: relative;
        cursor: pointer;
        white-space: nowrap;
        transition: color 0.3s ease;
    }
    
    .header-nav .nav-item:hover {
        color: #3b82f6;
    }
    
    .header-nav .nav-dropdown {
        position: relative;
        height: 100%;
    }
    
    /* 关键修改：下拉菜单居中 */
    .header-nav .nav-dropdown-content {
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        width: 100vw;
        max-width: 1200px;
        background: white;
        box-shadow: 0 10px 25px rgba(0,0,0,0.15);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        padding: 0;
        z-index: 1001;
        border-top: 2px solid #3b82f6;
        border-radius: 0 0 0.5rem 0.5rem;
        overflow: hidden;
        display: block !important;
    }
    
    /* 关键修改：悬停显示 */
    .header-nav .nav-dropdown:hover .nav-dropdown-content {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }
    
    .header-nav .dropdown-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 2rem 1rem;
    }
    
    .header-nav .dropdown-layout {
        display: flex;
        gap: 2rem;
        min-height: 350px;
    }
    
    .header-nav .dropdown-categories {
        flex: 0 0 250px;
        border-right: 1px solid #e5e7eb;
        padding-right: 2rem;
    }
    
    .header-nav .category-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: #1e293b;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid #3b82f6;
    }
    
    .header-nav .category-links {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header-nav .category-link {
        text-decoration: none;
        color: #64748b;
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
        border-radius: 0.375rem;
        transition: all 0.3s ease;
        border: 1px solid transparent;
        text-align: left;
        background: none;
        cursor: pointer;
        outline: none;
    }
    
    .header-nav .category-link:hover, 
    .header-nav .category-link.active {
        background: #f0f9ff;
        color: #3b82f6;
        border-color: #3b82f6;
    }
    
    .header-nav .dropdown-products {
        flex: 1;
    }
    
    .header-nav .category-content {
        display: none;
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    .header-nav .category-content.active {
        display: block;
    }
    
    .header-nav .brands-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }
    
    .header-nav .brand-card {
        background: #f8fafc;
        border-radius: 0.5rem;
        padding: 1.5rem;
        transition: all 0.3s ease;
        border: 1px solid #e2e8f0;
        cursor: pointer;
        text-align: center;
        display: flex;
        flex-direction: column;
        height: 200px;
        min-height: 200px;
    }
    
    .header-nav .brand-card:hover {
        background: #f0f9ff;
        border-color: #3b82f6;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    }
    
    .header-nav .brand-name {
        font-weight: 600;
        color: #1e293b;
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
        flex-shrink: 0;
    }
    
    .header-nav .brand-description {
        font-size: 0.875rem;
        color: #64748b;
        margin-bottom: 1rem;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1.4;
    }
    
    .header-nav .brand-btn {
        background: #3b82f6;
        color: white;
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 0.375rem;
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        transition: background 0.3s ease;
        width: 100%;
        text-decoration: none;
        display: block;
        text-align: center;
        flex-shrink: 0;
    }
    
    .header-nav .brand-btn:hover {
        background: #2563eb;
        color: white;
    }
    
    .header-nav .view-all {
        text-align: center;
        margin-top: 2rem;
        padding-top: 1.5rem;
        border-top: 1px solid #e5e7eb;
    }
    
    .header-nav .view-all-btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        color: #3b82f6;
        text-decoration: none;
        font-weight: 500;
        padding: 0.75rem 1.5rem;
        border: 1px solid #3b82f6;
        border-radius: 0.375rem;
        transition: all 0.3s ease;
    }
    
    .header-nav .view-all-btn:hover {
        background: #3b82f6;
        color: white;
    }
    
    .header-nav .control-btn {
        padding: 0.5rem 1rem;
        border: 2px solid #3b82f6;
        border-radius: 0.375rem;
        color: #3b82f6;
        text-decoration: none;
        font-weight: 500;
        transition: all 0.3s ease;
    }
    
    .header-nav .control-btn:hover {
        background: #3b82f6;
        color: white;
    }
    
    /* 添加下拉菜单的悬停区域 */
    .header-nav .nav-dropdown-content::before {
        content: '';
        position: absolute;
        top: -20px;
        left: 0;
        width: 100%;
        height: 20px;
        background: transparent;
    }
    
    /* 确保导航栏不会剪切下拉菜单 */
    .header-nav #navbar {
        overflow: visible !important;
    }
}